- Version:
- 0.2.3
- Mixes In:
- Object
- Source:
- See:
Example
class myEventDispatcher extends EventDispatcher {
constructor() {
this.dispatchEvent(new Event("created"));
}
}
Methods
addEventListener(type, listener, contextopt)
Registers a new event listener with the extending class instance.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
type |
String | The event type to register. | ||
listener |
function | The listening function to invoke on the event. | ||
context |
Object |
<optional> |
null | Unlike the traditional addEventListener parameter, this is
the context or scope in which to invoke the listening function (since we can't use capture phases).
If null, the listener is invoked in the context of the EventDispatcher or extending instance. |
- Source:
getListeners(type) → {Array}
Returns all registered listeners for a specific event type.
Parameters:
Name | Type | Description |
---|---|---|
type |
String | The event type to return registered listeners for. |
- Source:
Returns:
A list of registered event listener objects for the specific event.
Each object contains a
listener
function reference and an
execution context
reference.
- Type
- Array
removeEventListener(type, listener, contextopt)
Removes an event listener from the extending instance.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
type |
String | The event type to remove the function from. | ||
listener |
function | The listening function to remove. | ||
context |
Object |
<optional> |
null | The context or scope in which the listener exists. |
- Source: