new EventDispatcher()
Core EventDispatcher class that should be extended in case you need ability to fire custom events from an object
- Since:
- 1.0.0
- Source:
Members
events :Object
Object storing all event types.
Each event type is an array of callback functions that get executed when an event of that type of dispatched.
Type:
- Object
- Source:
Methods
addEventListener(eventType, callback) → {void}
Attaches an event handler to a specific event type
Parameters:
Name | Type | Description |
---|---|---|
eventType |
string | The type of the event you'd like to listen for |
callback |
function | The function to be executed when the event occurs |
- Source:
Returns:
- Type
- void
dispatchEvent(eventType, eventObj) → {void}
Fires an event on behalf of the object
Parameters:
Name | Type | Description |
---|---|---|
eventType |
string | The type of the event you'd like to fire |
eventObj |
Event | The actual event object that will be passed to listener functions. This can be used to store additional information for the situation. |
- Source:
Returns:
- Type
- void
removeEventListener(eventType, callback) → {void}
Removes a previously attached event to a specific event type.
Parameters:
Name | Type | Description |
---|---|---|
eventType |
string | The type of the event you'd like to unbind a handler for |
callback |
function | This must be a reference to the same Function object that has been set as a listener. Otherwise the removal will not take place. |
- Source:
Returns:
- Type
- void