innmind / event-bus
This package is abandoned and no longer maintained.
No replacement package was suggested.
Event dispatcher library
4.1.0
2021-02-06 09:54 UTC
Requires
- php: ~7.4|~8.0
- innmind/immutable: ~3.0
Requires (Dev)
- innmind/coding-standard: ^1.1
- phpunit/phpunit: ~9.0
- vimeo/psalm: ~4.1
README
Simple library to dispatch events to listeners; with the particularity that you can't order your listeners, listeners can't modify the event, listeners can't stop other listeners to be called and the event must be an object.
Instalation
composer require innmind/event-bus
Example
use function Innmind\EventBus\bootstrap; use Innmind\Immutable\Map; class MyEvent{} $echo = function(MyEvent $event): void { echo 'foo'; }; $dispatch = bootstrap()['bus']( Map::of('string', 'callable') (MyEvent::class, $echo) ); $dispatch(new MyEvent); // will print "foo"
All listeners must be callable
s and can listen to a specific class, a parent class or an interface.