LCMicroServiceEventListener

@protocol LCMicroServiceEventListener <NSObject>

Clients of an LCMicroService communicate with the JavaScript service through an event emitter interface. To listen for specific events, call LCMicroService.-addEventListener:listener:. The delegates will be called through this protocol.

In JavaScript, Node.js services trigger events by calling LiquidCore.emit(event, payload). The payload can be any JavaScript object and will get converted to the appropriate object in the host language (Swift/Objective-C).

  • Called when an event registered with -addEventListener:listener: is triggered from JavaScript.

    Declaration

    Objective-C

    - (void)onEvent:(LCMicroService *_Nonnull)service
              event:(NSString *_Nonnull)event
            payload:(id _Nullable)payload;

    Swift

    func onEvent(_ service: LCMicroService, event: Any!, payload: Any?)

    Parameters

    service

    The micro service that emitted the event.

    event

    The emitted event.

    payload

    An optional data object emitted with the event. The listener should know in advance the format emitted by the service.