EventEmitter

Core. EventEmitter

An EventEmitter class, for subscribing to events emitted by an object.

Constructor

new EventEmitter()

Source:
See:

Members

events :Map

The events table for this EventEmitter.

Source:
Type:
  • Map

Methods

(async) emit(eventName, dataopt) → {Promise.<Array>}

Emit an event with data.

Source:
Parameters:
Name Type Attributes Description
eventName String

the name of the event being emitted

data * <optional>

any data accompanying the event

Returns:
Type:
Promise.<Array>

off(eventName, func)

Unsubscribe a function from an event.

Source:
Parameters:
Name Type Description
eventName String

the name of the event to unsubscribe from

func function

the function to unsubscribe from the event

on(eventName, func) → {function}

Listen for an event to be emitted by this emitter.

Source:
Parameters:
Name Type Description
eventName String

the name of the event to listen for

func function

the function to call when the event is emitted

Returns:
Type:
function

a function that can be called to remove the listener

once(eventName, func) → {function}

Listen for an event to be emitted by this emitter, and only fire the callback function once.

Source:
Parameters:
Name Type Description
eventName String

the name of the event to listen for

func function

the function to call when the event is emitted

Returns:
Type:
function

a function that can be called to remove the listener

stop()

Remove all event listeners.

Source: