LCProcessDelegate

@protocol LCProcessDelegate <NSObject>

Clients must subclass an LCProcessDelegate to get state change information from the node.js process

  • Called when a node.js process is actively running. This is the one and only opportunity to start running JavaScript in the process. If the receiver returns from this method without executing asynchronous JS, the process will exit almost immediately afterward. This is the time to execute scripts.

    Note

    This method is called inside of the node.js process thread, so any JavaScript code called here is executed synchronously.

    Note

    In the event that an LCProcessDelegate is added by -addDelegate: after a process has already started, this method will be called immediately (in the process thread) if the process is still active. Otherwise, -onProcessExit:exitCode: will be called.

    Note

    Clients must hold a reference to the context for as long as they want the process to remain active. If the context is garbage collected, the process will be exited automatically in order to prevent misuse.

    Declaration

    Objective-C

    - (void)onProcessStart:(LCProcess *)process context:(JSContext *)context;

    Swift

    func onProcessStart(_ process: LCProcess!, context: JSContext!)

    Parameters

    process

    The node.js LCProcess object

    context

    The JavaScript JSContext for this process

  • Called when a node.js process has completed all of its callbacks and has nothing left to do. If there is any cleanup required, now is the time to do it. If the caller would like the process to abort its exit sequence, this is the time to either call [process keepAlive] or execute an asynchronous operation. If no callbacks are pending after this method returns, then the process will exit.

    Note

    This method is called inside of the node.js process thread, so any JavaScript code called here is executed synchronously.

    Declaration

    Objective-C

    - (void)onProcessAboutToExit:(LCProcess *)process exitCode:(int)code;

    Swift

    func onProcessAbout(toExit process: LCProcess!, exitCode code: Int32)

    Parameters

    process

    The node.js LCProcess object

    exitCode

    The node.js exit code

  • Called after a process has exited. The process is no longer active and cannot be used.

    Note

    In the event that an EventListener is added by [process addDelegate:] after a process has already exited, this method will be called immediately.

    Declaration

    Objective-C

    - (void)onProcessExit:(LCProcess *)process exitCode:(int)code;

    Swift

    func onProcessExit(_ process: LCProcess!, exitCode code: Int32)

    Parameters

    process

    The defunct node.js LCProcess object

    exitCode

    The node.js exit code

  • Called in the event of an LCProcess failure

    Declaration

    Objective-C

    - (void)onProcessFailed:(LCProcess *)process exception:(NSException *)exception;

    Swift

    func onProcessFailed(_ process: LCProcess!, exception: NSException!)

    Parameters

    process

    The node.js LCProcess object

    exception

    The thrown exception