Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.
/ EventBus Public archive

Event dispatcher heavily inspired by simple-bus/message-bus

License

Notifications You must be signed in to change notification settings

Innmind/EventBus

Repository files navigation

EventBus

Build Status codecov Type Coverage

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 callables and can listen to a specific class, a parent class or an interface.

About

Event dispatcher heavily inspired by simple-bus/message-bus

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages