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
LCMicroServicehas successfully started.Listens for when the
LCMicroServicehas 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
serviceThe micro service which has now started.
-
Optional listener for when the
LCMicroServicehas successfully exited.Listens for when the
LCMicroServicehas exited gracefully. TheLCMicroServiceis no longer available and is shutting down.Called immediately before the
LCMicroServiceexits. 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 anyLCMicroService.Declaration
Objective-C
- (void)onExit:(LCMicroService *_Nonnull)service exitCode:(int)exitCode;Swift
optional func onExit(_ service: LCMicroService, exitCode: Int32)Parameters
serviceThe micro service which is now exiting.
exitCodeThe exit code emitted by the Node.js process.
-
Optional listener for when the
LCMicroServicehas exited unexpectedly.Listens for any errors that may cause the
LCMicroServiceto shut down unexpectedly. TheLCMicroServiceis 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
serviceThe micro service which failed.
exceptionThe thrown error.
View on GitHub
Install in Dash
LCMicroServiceDelegate Protocol Reference