Constructor
# new base/EventDispatcher()
An event dispatcher, implementing the Observer design pattern.
Methods
# addEventListener(type, handler, onceopt) → {ax/EventDispatcher}
Registers an event listener for a certain type.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
String
|
event type |
|
handler |
function
|
event listener function |
|
once |
Boolean
|
<optional> |
set to true if listener will be called only once |
current event dispatcher, for easier chaining
ax/EventDispatcher
# dispatchEvent(type, data, handleError) → {Boolean}
Dispatches an event with additional data.
Parameters:
Name | Type | Description |
---|---|---|
type |
String
|
event type to dispatch |
data |
Object
|
the event data object |
handleError |
Boolean
|
catch the errors on thrown in listener and handle gracefully. Default is false. |
result dispatch success for true
Boolean
# removeAllListeners() → {ax/EventDispatcher}
Removes all event listeners.
- See:
-
- ax/EventDispatcher#removeEventListener
current event dispatcher, for easier chaining
ax/EventDispatcher
# removeEventListener(type, handleropt) → {ax/EventDispatcher}
Removes one or more event listeners.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
xdk-ax/evt
|
String
|
Event type |
|
handler |
function
|
<optional> |
event listener function. If not provided, all listeners will be removed for the specific type. |
current event dispatcher, for easier chaining
ax/EventDispatcher