Class: EventEmitter

EventEmitter


new EventEmitter()

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

Methods


emit(event)

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

eventNames()

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

listenerCount(event)

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

listeners(event)

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

on(event, fn [, context])

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

once(event, fn [, context])

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

removeAllListeners( [event])

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

removeListener(event, fn, context, once)

Remove the listeners of a given event.
Parameters:
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.
Source:
Returns:
`this`.
Type
EventEmitter