Class: EventEmitter

EventEmitter

new EventEmitter ()

Minimal `EventEmitter` interface that is molded against the Node.js `EventEmitter` interface.

Methods

emit (event)Boolean

Calls each of the listeners registered for a given event.
Name Type Description
event String | Symbol The event name.
Returns:
Type Description
Boolean `true` if the event had listeners, else `false`.

eventNames ()Array

Return an array listing the events for which the emitter has registered listeners.
Returns:
Type Description
Array

listenerCount (event)Number

Return the number of listeners listening to a given event.
Name Type Description
event String | Symbol The event name.
Returns:
Type Description
Number The number of listeners.

listeners (event)Array

Return the listeners registered for a given event.
Name Type Description
event String | Symbol The event name.
Returns:
Type Description
Array The registered listeners.

on (event, fn, context)EventEmitter

Add a listener for a given event.
Name Type Default Description
event String | Symbol The event name.
fn function The listener function.
context * this optional The context to invoke the listener with.
Returns:
Type Description
EventEmitter `this`.

once (event, fn, context)EventEmitter

Add a one-time listener for a given event.
Name Type Default Description
event String | Symbol The event name.
fn function The listener function.
context * this optional The context to invoke the listener with.
Returns:
Type Description
EventEmitter `this`.

removeAllListeners (event)EventEmitter

Remove all listeners, or those of the specified event.
Name Type Description
event String | Symbol optional The event name.
Returns:
Type Description
EventEmitter `this`.

removeListener (event, fn, context, once)EventEmitter

Remove the listeners of a given event.
Name Type Description
event String | Symbol The event name.
fn function Only remove the listeners that match this function.
context * Only remove the listeners that have this context.
once Boolean Only remove one-time listeners.
Returns:
Type Description
EventEmitter `this`.