LCMicroServiceDelegate

@protocol LCMicroServiceDelegate <NSObject>

An LCMicroService may have an optional delegate to listen for events on start, exit and error conditions.

  • Optional listener for when the LCMicroService has successfully started.

    Listens for when the LCMicroService has been inititialized and the environment is ready to receive event listeners. This is called after the Node.js environment has been set up, but before the micro service JavaScript code has been executed. It is safe to add any event listeners here, but emitted events will not be seen by the JavaScript service until its code has been run. The JavaScript code should emit an event to let the host know that it is ready to receive events.

    Declaration

    Objective-C

    - (void)onStart:(LCMicroService *_Nonnull)service;

    Swift

    optional func onStart(_ service: LCMicroService)

    Parameters

    service

    The micro service which has now started.

  • Optional listener for when the LCMicroService has successfully exited.

    Listens for when the LCMicroService has exited gracefully. The LCMicroService is no longer available and is shutting down.

    Called immediately before the LCMicroService exits. This is a graceful exit, and is mutually exclusive with the -onError:exception: method. Only one of either the exit listener or error listener will be called from any LCMicroService.

    Declaration

    Objective-C

    - (void)onExit:(LCMicroService *_Nonnull)service exitCode:(int)exitCode;

    Swift

    optional func onExit(_ service: LCMicroService, exitCode: Int32)

    Parameters

    service

    The micro service which is now exiting.

    exitCode

    The exit code emitted by the Node.js process.

  • Optional listener for when the LCMicroService has exited unexpectedly.

    Listens for any errors that may cause the LCMicroService to shut down unexpectedly. The LCMicroService is no longer available and may have already crashed.

    Called upon an exception state. This is an unexpected exit, and is mutually exclusive with the -onExit:exitCode: method. Only one of either the exit listener or error listener will be called from any MicroService.

    Declaration

    Objective-C

    - (void)onError:(LCMicroService *_Nonnull)service
          exception:(NSException *_Nonnull)exception;

    Swift

    optional func onError(_ service: LCMicroService, exception: Any!)

    Parameters

    service

    The micro service which failed.

    exception

    The thrown error.