Class: EventEmitter

Class: EventEmitter

EventEmitter

new EventEmitter()

This class allows to emit events like node.js. Basically it's equivalent to node.js EventEmitter.

Source:

Methods

emit(event)

Emits the event. This will trigger all the listener with that event type. You can supply listener function's arguments by appending arguments after the 'event' parameter.

Parameters:
Name Type Description
event String

The name of the event.

args...

Arguments to supply to listeners.

Source:

listeners(event) → {Array}

Returns the array of listeners with specified event type.

Parameters:
Name Type Description
event String

The name of the event.

Source:
Returns:

An array holding event listeners.

Type
Array

on(event, listener)

Registers a listener.

Parameters:
Name Type Description
event String

The name of the event.

listener function

The function to be triggered.

Source:

once(event, listener)

Registers a one-time listener. The listener will be removed after being triggered once.

Parameters:
Name Type Description
event String

The name of the event.

listener function

The function to be triggered.

Source:

removeAllListeners(event)

Removes all the listener with specified event type. If event parameter is not set, it will remove all the listener of all types.

Parameters:
Name Type Argument Description
event String <optional>

The name of the event.

Source:

removeListener(event, listener)

Removes the listener.

Parameters:
Name Type Description
event String

The name of the event.

listener function

The function to be removed.

Source: