TEventDispatcher
Basic Event Dispatcher trait.
Table of Contents
Methods
- DispatchEvent() : object|null
- Dispatches an event.
- HandleEvent() : self
- Adds an event handler.
- RemoveHandler() : self
- Removes an event handler.
Methods
DispatchEvent()
Dispatches an event.
public
DispatchEvent(string|Event $event[, mixed $args = null ][, bool $async = false ]) : object|null
Parameters
- $event : string|Event
-
The event object or its name.
- $args : mixed = null
-
Additional arguments to pass to the event handlers.
- $async : bool = false
-
Whether to dispatch the event asynchronously.
Return values
object|null —The event object with updated arguments, or null if the event does not exist.
HandleEvent()
Adds an event handler.
public
HandleEvent(array<string|int, mixed>|string $ename, mixed $listener) : self
Parameters
- $ename : array<string|int, mixed>|string
-
The event name or an array of event names.
- $listener : mixed
-
The event handler.
Return values
selfRemoveHandler()
Removes an event handler.
public
RemoveHandler(string $ename, mixed $listener) : self
Parameters
- $ename : string
-
The event name.
- $listener : mixed
-
The event handler to remove.