thruster / 事件发射器
Thruster 事件发射器组件
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-09-14 03:11:17 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.cn/packages/thruster/event-emitter)
Thruster 事件发射器组件。
安装
通过 Composer
$ composer require thruster/event-emitter
用法
创建发射器
$emitter = new EventEmitter();
添加监听器
$emitter->on('foo.bar', function (Foo $bar) { // ... Something happend });
发射事件
$emitter->emit('foo.bar', [$fooBar]);
使用高级事件发射器
$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));
测试
$ composer test
贡献
请参阅CONTRIBUTING和CONDUCT以获取详细信息。
许可证
请参阅许可证文件以获取更多信息。