LCSurface
@protocol LCSurface <NSObject>
An LCSurface
is a UI interaction layer with an LCMicroService
.
-
The canonical name of the surface.
Declaration
Objective-C
@property (readonly, copy, atomic, class) NSString *SURFACE_CANONICAL_NAME;
Swift
static var surface_CANONICAL_NAME: String! { get }
-
A version string of the format
<major>.<minor>.<patch>
for the surface.Declaration
Objective-C
@property (readonly, copy, atomic, class) NSString *SURFACE_VERSION;
Swift
static var surface_VERSION: String! { get }
-
Binds a surface to an
LCMicroService
. This gives the surface an opportunity to bind any native functions required by the module.Declaration
Objective-C
- (void)bind:(LCMicroService *)service export:(JSValue *)exportObject config:(JSValue *)config onBound:(LCOnSuccessHandler)onBound onError:(LCOnFailHandler)onError;
Swift
func bind(_ service: LCMicroService!, export exportObject: JSValue!, config: JSValue!, onBound: LCOnSuccessHandler!, onError: LCOnFailHandler!)
Parameters
service
The micro service to bind.
exportObject
An object which will be passed back to the caller where the surface may export its JS bindings
config
An optional configuration parameter passed from JavaScript
onBound
A block which must be called if and when binding is successful
onError
A Block which must be called if and only if binding fails
-
Attaches an
LCMicroService
to the UI.Declaration
Objective-C
- (UIView<LCSurface> *)attach:(LCMicroService *)service onAttached:(LCOnSuccessHandler)onAttachedHandler onError:(LCOnFailHandler)onError;
Swift
func attach(_ service: LCMicroService!, onAttached onAttachedHandler: LCOnSuccessHandler!, onError: LCOnFailHandler!) -> (UIView & LCSurface)!
Parameters
service
The
LCMicroService
to attach.onAttachedHandler
A block which must be called if and when attaching is successful
onError
A Block which must be called if and only if attaching fails
Return Value
The UIView of the newly attached surface.
-
Detaches any currently attached
LCMicroService
. TheLCSurface
may then be ready to be discarded or reattached to anotherLCMicroService
.Declaration
Objective-C
- (void)detach;
Swift
func detach()
-
Detaches and clears the LCSurface. This is the preferred method when the
LCSurface
is to be reused.-detach
may leave behind some UI state, as it expects that the micro service may later be re-attached.-reset
clears any UI state back to a fresh state.Declaration
Objective-C
- (void)reset;
Swift
func reset()