Class: EventEmitter

EventEmitter~ EventEmitter

An Event Emitter class


new EventEmitter()

Create a new Event Emitter

Methods


emit(eventName, data)

Emit an event with data

Parameters:
Name Type Description
eventName String

The name of the event being emitted

data Any

Data accompanying the event

Returns:

Returns the event emitter

Type
Object

off(eventName, func)

Unsubscribe a function from an event

Parameters:
Name Type Description
eventName String

The name of the event to unsubscribe from

func function

The function to unsubscribe from the event

Returns:

Returns the event emitter

Type
Object

on(eventName, function)

Add an event listener to this emitter

Parameters:
Name Type Description
eventName String

The name of the event to subscribe to

function function

The function to trigger when the event is emitted

Returns:

Returns the event emitter for method chaining

Type
Object