talesoft / tale-event
A PSR-14 implementation
0.3.0
2020-03-11 20:30 UTC
Requires
- php: >=7.4.0
- psr/event-dispatcher: ^1.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.0
Requires (Dev)
- phpunit/phpunit: ^8.4
- squizlabs/php_codesniffer: ^3.5
This package is auto-updated.
Last update: 2024-10-12 07:00:40 UTC
README
Tale Event
What is Tale Event?
A PSR-14 Event Dispatcher implementation
Installation
composer req talesoft/tale-event
Usage
use Tale\Event\ListenerProvider\ReflectionListenerProvider; use Tale\EventDispatcher; $provider = new ReflectionListenerProvider(); $dispatcher = new EventDispatcher($provider); class MyEvent { private $message = ''; public function setMessage(string $message): void { $this->message = $message; } public function getMessage(): string { return $this->message; } } $provider->addListener(function (MyEvent $event) { $event->setMessage('Hello from listener!'); }); $event = new MyEvent(); $dispatcher->dispatch($event); echo $event->getMessage(); // "Hello from listener!"