flextype-components / event
Event Component provides a versatile tool to manage events in your app.
v1.0.4
2018-05-31 18:17 UTC
Requires
- php: ^7.1.3
README
Event Component provides a versatile tool to manage events in your app.
Installation
composer require flextype-components/event
Usage
use Flextype\Component\Event\Event;
Add new listeners
Event::addListener('event_name', function() { echo 'Test Event 1'; }, 1); Event::addListener('event_name', function() { echo 'Test Event 2'; }, 2);
Remove all listeners for current event.
Event::removeAllListeners('event_name');
Check is listeners exists for current event.
if (Event::hasListeners('event_name')) { // do something... }
Dispatch all listeners of the given event.
Event::dispatch('event_name');
Get listeners array
$listeners = Event::getListeners();
License
See LICENSE