Module ringo/events
Exports an EventEmitter class that provides methods
to emit events and register event listeners.
This class provides methods to emit events and add or remove event listeners.
The EventEmitter function can be used as constructor or as mixin. Use the
new keyword to construct a new EventEmitter:
var emitter = new EventEmitter();
To add event handling methods to an existing object, call or apply the
EventEmitter function with the object as this:
EventEmitter.call(object);
EventEmitter.prototype.addListener
(type, listener)
Add a listener function for the given event.
Parameters
| string |
type |
the event type |
| function |
listener |
the listener |
EventEmitter.prototype.emit
(type, [args...])
Emit an event to all listeners registered for this event type
Parameters
| string |
type |
type the event type |
|
[args...] |
optional arguments to pass to the listeners |
Returns
|
true if the event was handled by at least one listener, false otherwise |
Throws
EventEmitter.prototype.listeners
(type)
Get an array containing the listener functions for the given event.
If no listeners exist for the given event a new array is created.
Changes on the return value will be reflected in the EventEmitter instance.
Parameters
| string |
type |
the event type |
EventEmitter.prototype.on
(type, listener)
Add a listener function for the given event. This is a shortcut for
addListener()
Parameters
| string |
type |
the event type |
| function |
listener |
the listener |
Remove all listener function for the given event.
Parameters
| string |
type |
the event type |
EventEmitter.prototype.removeListener
(type, listener)
Remove a listener function for the given event.
Parameters
| string |
type |
the event type |
| function |
listener |
the listener |