Recommend this page to a friend! |
Classes of butani kartik | PHP WebSockets Server Example | vendor/evenement/evenement/doc/01-api.md | Download |
|
DownloadAPIThe API that événement exposes is defined by the
on($event, callable $listener)Allows you to subscribe to an event. Example:
Since the listener can be any callable, you could also use an instance method instead of the anonymous function:
This has the benefit that listener does not even need to know that the emitter exists. You can also accept more than one parameter for the listener:
once($event, callable $listener)Convenience method that adds a listener which is guaranteed to only be called once. Example:
emit($event, array $arguments = [])Emit an event, which will call all listeners. Example:
The second argument to emit is an array of listener arguments. This is how you specify more args:
listeners($event)Allows you to inspect the listeners attached to an event. Particularly useful to check if there are any listeners at all. Example:
removeListener($event, callable $listener)Remove a specific listener for a specific event. removeAllListeners($event = null)Remove all listeners for a specific event or all listeners all together. This is useful for long-running processes, where you want to remove listeners in order to allow them to get garbage collected. |