Classes
Methods
addEventListener()
Alias for on.
destroy()
Removes all event handlers.
dispatchEvent(…args) → {boolean}
This method is similar to emit() except that it returns false if an event handler stopped event processing.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
args |
* |
<repeatable> |
Event arguments. |
Returns:
- The return value is false, if an event handler cancelled the event processing by returning something other than undefined. Otherwise, the return value is true.
- Type
- boolean
emit(…args)
Emit an event.
Event processing stops when the first event handler returns anything other than undefined.
If an event handler throws an exception, it is logged to the developer console.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
args |
* |
<repeatable> |
Event arguments. |
Returns:
- Returns the value returned by the last event handler called or undefined.
hasEventListener(name, callback)
Returns true if the specified event handler is registered. If no callback is specified, true is returned if any event handler is installed for the given event name.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The event name. |
callback |
function | The event callback. |
off(name, callback)
Removes an event handler.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The event name. |
callback |
function | The event callback. |
on(name, callback)
Register an event handler. If the same event handler is already registered, an exception is thrown.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The event name. |
callback |
function | The event callback. |
once(name, callback) → {function}
Register an event handler to be executed once.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The event name. |
callback |
function | The event callback. |
Returns:
- The return value is a function which can be called to remove the event subscription.
- Type
- function
removeEventListener()
Alias for off.
subscribe(name, callback) → {function}
Register an event handler. If the same event handler is already registered, an exception is thrown.
This method returns a function which removes the event handler.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The event name. |
callback |
function | The event callback. |
Returns:
- The return value is a function which can be called to remove the event subscription.
- Type
- function