EventDispatcher Class
Basic EventDispatcher adapated from Symphony's EventDispatcher but simplified to mirror the Canteen Client dispatcher API.
Methods
getListeners
(
Array
private
-
[eventType=null]
Gets the listeners of a specific event or all listeners.
Parameters:
-
[eventType=null]
String optionalThe type of the event
Returns:
Array:
The event listeners for the specified event, or all event listeners by event name
has
(
Boolean
-
eventType
Checks whether an event has any registered listeners.
Parameters:
-
eventType
StringThe name of the event
Returns:
Boolean:
true if the specified event has any listeners, false otherwise
off
(
EventDispatcher
-
eventType
-
[listener=null]
Removes an event listener from the specified events.
Parameters:
Returns:
EventDispatcher:
Reference reference of this for chaining
on
(
EventDispatcher
-
eventType
-
listener
-
[priority=0]
Adds an event listener that listens on the specified events.
Parameters:
Returns:
EventDispatcher:
Reference reference of this for chaining
sortListeners
(
private
-
eventType
Sorts the internal list of listeners for the given event by priority.
Parameters:
-
eventType
StringThe name of the event.