nimp/observer
最新稳定版本:v1.0.4
Composer 安装命令:
composer require nimp/observer
包简介
minimal realization lets the text editor object notify other service objects about changes in its state
README 文档
README
Minimalistic implementation of event dispatching according to PSR-14: EventDispatcher + ListenerProvider.
Installation
composer require nimp/observer
Quick start
final class MyListener implements EventListenerInterface { public function events(): iterable { yield StartedEvent::class => $this->onStarted(...); yield MyEvent::class => 'onMyEvent'; yield MyStoppableEvent::class => function (MyStoppableEvent $e): void { // handle and stop propagation if needed $e->stop(); }; } public function onStarted(StartedEvent $event): void { // handle StartedEvent } public function onMyEvent(object $event): void { // handle MyEvent } } $provider = new ListenerProvider(); $provider->addListeners(new MyListener()); $dispatcher = new EventDispatcher($provider);
Tests
composer install && composer test
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-29