Class MOXMAN_Util_EventDispatcher
| Inheritance | MOXMAN_Util_EventDispatcher |
|---|
This class is used for event delegation. You simply add event listeners to it and then you can fire events to those listeners.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Constructs a new EventDispatcher instance. | MOXMAN_Util_EventDispatcher |
| add() | Add a new event listener/observer to the specified event name. | MOXMAN_Util_EventDispatcher |
| clear() | Remove all registred event listeners from the specified object. | MOXMAN_Util_EventDispatcher |
| dispatch() | Dispatches an event out to any listeners/observers. | MOXMAN_Util_EventDispatcher |
| hasListeners() | Returns true/false if there is any listeners/observers for the specific event name. | MOXMAN_Util_EventDispatcher |
| remove() | Remove a new event listener/observer from the event specified by name. | MOXMAN_Util_EventDispatcher |
Method Details
Constructs a new EventDispatcher instance.
| public void __construct ( ) |
Add a new event listener/observer to the specified event name.
| public Array add ( $name, $func, $obj ) | ||
| $name | string | Event name to add listeners/observers to. |
| $func | string | Function name to execute ones the event occurs. |
| $obj | Object | Object to execute the specified function on. |
| return | Array | Array item with the observer function and object. |
|---|---|---|
Remove all registred event listeners from the specified object.
| public void clear ( $obj ) | ||
| $obj | Object | Object to remove event listeners from. |
Dispatches an event out to any listeners/observers.
| public Object dispatch ( $sender, $name, $args ) | ||
| $sender | Object | Sender reference to send as the first argument to all listeners/observers. |
| $name | string | Event name to dispatch for example "FileAction". |
| $args | Object | Event arguments object to pass to each listener/observer. |
| return | Object | The event arguments object that got passed around. |
|---|---|---|
Returns true/false if there is any listeners/observers for the specific event name.
| public Bool hasListeners ( $name ) | ||
| $name | string | Event name to check for listeners on. |
| return | Bool | True/false if there is any registred listeners. |
|---|---|---|
Remove a new event listener/observer from the event specified by name.
| public Array remove ( $name, $func, $obj ) | ||
| $name | string | Event name remote listener/observer from. |
| $func | string | Function name to no longer execute ones the event occurs. |
| $obj | Object | Object to no longer execute the specified function on. |
| return | Array | Array item with the observer function and object that got removed or null if it wasn't found. |
|---|---|---|