Minimal `EventEmitter` interface that is molded against the Node.js
`EventEmitter` interface.
Methods
-
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`. -
Return an array listing the events for which the emitter has registered listeners.
Returns:
Type Description Array -
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. -
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`.