Simple Event and EventManager
- PHP >= 5.6
composer require "fastd/event:1.0.x-dev" -vvv
$event = new \FastD\Event\Event('demo', function () {
return 'demo event';
});
$result = $event->broadcast();
$this->assertEquals(['demo event'], $result);
$eventDispatch = new \FastD\Event\EventDispatcher();
$eventDispatch->on('demo', new DemoListener());
echo $eventDispatch->trigger('demo');
$this->expectOutputString('handle ok');
phpunit