OO.EventEmitter()

Show:

new EventEmitter()

...

Members

(private) bindings

Storage of bound event handlers by event name.

Storage of bound event handlers by event name.

Properties:
Name Type Description
bindings Object
Source:

Methods

connect(context, methods) → {OO.EventEmitter}

Connect event handlers to an object.

Connect event handlers to an object.

Parameters:
Name Type Description
context Object

Object to call methods on when events occur

methods Object.<string, string> | Object.<string, function()> | Object.<string, Array>

List of event bindings keyed by event name containing either method names, functions or arrays containing method name or function followed by a list of arguments to be passed to callback before emitted arguments.

Source:
Returns:
Type
OO.EventEmitter

disconnect(context, methodsopt) → {OO.EventEmitter}

Disconnect event handlers from an object.

Disconnect event handlers from an object.

Parameters:
Name Type Attributes Description
context Object

Object to disconnect methods from

methods Object.<string, string> | Object.<string, function()> | Object.<string, Array> <optional>

List of event bindings keyed by event name. Values can be either method names, functions or arrays containing a method name. NOTE: To allow matching call sites with connect(), array values are allowed to contain the parameters as well, but only the method name is used to find bindings. Tt is discouraged to have multiple bindings for the same event to the same listener, but if used (and only the parameters vary), disconnecting one variation of (event name, event listener, parameters) will disconnect other variations as well.

Source:
Returns:
Type
OO.EventEmitter

emit(event, …args) → {boolean}

Emit an event.

Emit an event.

Parameters:
Name Type Attributes Description
event string

Type of event

args any <repeatable>

First in a list of variadic arguments passed to event handler (optional)

Source:
Returns:

Whether the event was handled by at least one listener

Type
boolean

off(event, methodopt, contextopt) → {OO.EventEmitter}

Remove a specific listener from a specific event.

Remove a specific listener from a specific event.

Parameters:
Name Type Attributes Default Description
event string

Type of event to remove listener from

method function | string <optional>

Listener to remove. Must be in the same form as was passed to "on". Omit to remove all listeners.

context Object <optional>
null

Context object function or method call

Source:
Throws:

Listener argument is not a function or a valid method name

Type
Error
Returns:
Type
OO.EventEmitter

on(event, method, argsopt, contextopt) → {OO.EventEmitter}

Add a listener to events of a specific event.

Add a listener to events of a specific event.

The listener can be a function or the string name of a method; if the latter, then the name lookup happens at the time the listener is called.

Parameters:
Name Type Attributes Default Description
event string

Type of event to listen to

method function | string

Function or method name to call when event occurs

args Array <optional>

Arguments to pass to listener, will be prepended to emitted arguments

context Object <optional>
null

Context object for function or method call

Source:
Throws:

Listener argument is not a function or a valid method name

Type
Error
Returns:
Type
OO.EventEmitter

once(event, listener) → {OO.EventEmitter}

Add a one-time listener to a specific event.

Add a one-time listener to a specific event.

Parameters:
Name Type Description
event string

Type of event to listen to

listener function

Listener to call when event occurs

Source:
Returns:
Type
OO.EventEmitter