Emitter

Emitter

new Emitter(logger)

Subset of node's Emitter class

Parameters:
Name Type Description
logger Object

Optional logger instance. Must comply to the Console interface.

Source:

Methods

emit(eventName) → {boolean}

Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments to each.

Parameters:
Name Type Description
eventName string

The name of the event.

Source:

on(eventName, listener) → {Emitter}

Adds the listener function to the end of the listeners array for the event named eventName.

Parameters:
Name Type Description
eventName string

The name of the event.

listener function

Listener fn that handles the evt.

Source:

once(eventName, listener) → {Emitter}

Adds a one time listener function for the event named eventName. The next time eventName is triggered, this listener is removed and then invoked.

Parameters:
Name Type Description
eventName string

The name of the event.

listener function

Listener fn that handles the evt.

Source:

removeAllListeners(eventName) → {Emitter}

Removes all listeners, or those of the specified eventName.

Parameters:
Name Type Description
eventName string

The name of the event. Optional if omitted all listeners will be removed.

Source:

removeListener(eventName, listener) → {Emitter}

Removes the specified listener from the listener array for the event named eventName.

Parameters:
Name Type Description
eventName string

The name of the event.

listener function

Listener fn that handles the evt.

Source: