Class: EventEmitter

EventEmitter()

Registers and emits named events.

Constructor

new EventEmitter()

Source:

Methods

emit(name, …argsopt)

Calls all previously added listeners for the given event name.
Parameters:
Name Type Attributes Description
name string
args * <optional>
<repeatable>
Source:

hasListeners(nameopt) → {boolean}

Checks whether there are any listeners for the specified event.
Parameters:
Name Type Attributes Description
name string <optional>
The name of the event. If omitted, checks whether there are any listeners for any event.
Source:
Returns:
Type
boolean

listeners(name) → {Array.<function()>}

Returns a copy of the array of listeners for the specified event.
Parameters:
Name Type Description
name string
Source:
Returns:
Type
Array.<function()>

off(name, listener)

Removes a listener for the specified event name.
Parameters:
Name Type Description
name string
listener function
Source:

on(name, listener)

Adds a listener for the specified event name.
Parameters:
Name Type Description
name string
listener function
Source:

once(name) → {Promise}

Adds a one time listener and returns a promise that is resolved the next time the specified event is emitted.
Parameters:
Name Type Description
name string
Source:
Returns:
Type
Promise