thruster / event-emitter
Thruster EventEmitter Component
1.1.0
2016-01-12 15:31 UTC
Requires
- php: >=7.0
Requires (Dev)
- phpunit/phpunit: ~5.0
This package is auto-updated.
Last update: 2024-11-14 03:27:13 UTC
README
[] (https://github.com/ThrusterIO/event-emitter/releases) [] (LICENSE) [] (https://travis-ci.org/ThrusterIO/event-emitter) [] (https://scrutinizer-ci.com/g/ThrusterIO/event-emitter) [] (https://scrutinizer-ci.com/g/ThrusterIO/event-emitter) [] (https://packagist.org/packages/thruster/event-emitter)
The Thruster EventEmitter Component.
Install
Via Composer
$ composer require thruster/event-emitter
Usage
Creating an Emitter
$emitter = new EventEmitter();
Adding Listeners
$emitter->on('foo.bar', function (Foo $bar) { // ... Something happend });
Emitting Events
$emitter->emit('foo.bar', [$fooBar]);
Using Advance Event Emitter
$emitter = new AdvanceEventEmitter(); $emitter->on('foo.bar', function (EventInterface $event) { // ... Do something good $event->stopPropagation(); // you can stop further execution }); $emitter->on('foo.bar', function (EventInterface $event) { // ... Never gets called }); $emitter->emit('foo.bar', new Event($fooBar));
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CONDUCT for details.
License
Please see License File for more information.