An event emitter that has better support async methods giving the emitter the option to execute event handlers async in sequence instead of in parallel.

All handlers can be removed using

If async event handlers throw an error when hideExceptions is set to false the emitter will receive the error.

Example

// Prints "Hello world" after 1 second
// before "End!"
const emitter = new AsyncEventEmitter();
emitter.on('hello', async (params) => {
await new Promise(resolve => setTimeout(resolve, 1000));
console.log('Hello', params);
});
// pass `{async: true}` to not await the handler completion
// which will print "End!" before "Hello world"
await emitter.emit('hello', 'world');
console.log('End!');

Hierarchy

Constructors

Properties

cancelled: undefined | true
checkInterval: number = 1000
compressionLevel: number = 7

Deflate compression level of the Salesforce deployment package (zip file)

deployOptions: DeployOptions
deploymentId: string
lastPrintedLogStamp: number = 0
lastStatus: DeployResult
logInterval: number = 5000

Interval in milliseconds in which data is reported back on the progress event

logger: Logger = ...
nextProgressTimeoutId: Timeout
pollCount: number = 0

Accessors

  • get isCompleted(): boolean
  • Determine if the deployment has completed, either successfully or with errors or warnings. Returns false if the deployment has not yet started. Returns true if the deployment is completed.

    Returns boolean

Methods

  • Handles the error that occurs when emitting a callback event.

    Parameters

    • err: unknown

      The error that occurred.

    • event: string

      The name of the event.

    • failedCallback: EventReceiver<any>

      The failed callback event receiver.

    Returns void

  • Removes all listeners, or those of the specified event.

    It is bad practice to remove listeners added elsewhere in the code, particularly when the EventEmitter instance was created by some other component or module (e.g. sockets or file streams).

    Returns a reference to the EventEmitter, so that calls can be chained.

    Type Parameters

    Parameters

    • Optional event: K

      event type to remove listeners for if not specified all listeners are removed

    Returns void