codin / events
PSR-14 Event dispatcher
1.0.0
2022-12-16 10:22 UTC
Requires
- php: >=7.3
- psr/event-dispatcher: @stable
- psr/log: @stable
Requires (Dev)
- friendsofphp/php-cs-fixer: @stable
- phpspec/phpspec: @stable
- phpstan/phpstan: @stable
This package is auto-updated.
Last update: 2024-10-16 14:16:09 UTC
README
PSR-14 Compatible event dispatcher
Usage
class MyListener implements \Psr\EventDispatcher\ListenerProviderInterface { public function getListenersForEvent(object $event) : iterable { yield static function (MyEvent $event) { echo "$event->message\n"; }; } } class MyEvent { public string $message = 'Hello World'; } $dispatcher = new Codin\Events\EventDispatcher(); $dispatcher->registerListener(new MyListener()); $dispatcher->dispatch(new MyEvent());