sy / event
A simple event dispatcher PSR14 compatible
1.1.0
2021-09-27 12:28 UTC
This package is auto-updated.
Last update: 2024-10-27 19:50:19 UTC
README
PSR-14 compatible event dispatcher provides an ability to dispatch events and listen to events dispatched
Installation
Install the latest version with
$ composer require sy/event
Basic Usage
<?php use Sy\Event\EventDispatcher; use Sy\Event\Event; $eventDispatcher = new EventDispatcher(); // Add an event listener on an event named "myEvent" $eventDispatcher->addListener('myEvent', function (object $event) { echo 'An event occurs: ' . $event->getName(); }); // Dispatch an event called "myEvent" $eventDispatcher->dispatch(new Event('myEvent'));