Class puredom.EventEmitter
-
Fire events and listen for fired events.
- Defined in: EventEmitter.js
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
Creates a new EventEmitter instance.
|
Method Summary
| Method Attributes | Method Name and Description |
|---|---|
|
emit
(type, args)
Fire an event of a given type.
|
|
|
on
(type, handler)
Register an event listener on the instance.
|
|
|
once
(type, handler)
A version of .on() that removes handlers once they are called.
|
|
|
removeListener
(type, handler)
Remove an event listener from the instance.
|
Class Detail
puredom.EventEmitter()
Creates a new EventEmitter instance.
Method Detail
-
{Array} emit(type, args)Fire an event of a given type.
Pass a comma-separated list fortypeto fire multiple events at once.- Parameters:
- {String} type
- Event type, or a comma-seprated list of event types.
- {Array} args Optional
- Arguments to pass to each handler. Non-Array values get auto-boxed into an Array.
- Returns:
- {Array} an Array of handler return values. The Array also has "truthy" and "falsey" properties indicating if any handlers returned
trueorfalse, respectively.
-
{this} on(type, handler)Register an event listener on the instance.
- Parameters:
- {String} type
- An event type, or a comma-seprated list of event types.
- {Function} handler
- A function to call in response to events of the given type.
- Returns:
- {this}
-
{this} once(type, handler)A version of .on() that removes handlers once they are called.
- Parameters:
- {String} type
- An event type, or a comma-seprated list of event types.
- {Function} handler
- A function to call in response to events of the given type. Will only be called once.
- Returns:
- {this}
- See:
- puredom.EventEmitter#on
-
{this} removeListener(type, handler)Remove an event listener from the instance.
- Parameters:
- {String} type
- An event type, or a comma-seprated list of event types.
- {Function} handler
- A reference to the handler, as was originally passed to {puredom.EventEmitter#addEventListener}.
- Returns:
- {this}