fwk/events
Composer 安装命令:
composer require fwk/events
包简介
Lightweight Event Dispatcher for Happy Developers
README 文档
README
Event Dispatcher for PHP 5.4+
Installation
Via Composer:
{
"require": {
"fwk/events": "dev-master",
}
}
If you don't use Composer, you can still download this repository and add it
to your include_path PSR-0 compatible
Documentation
Adding Listeners
use Fwk\Events\Dispatcher, Fwk\Events\Event; $evd = new Dispatcher(); // closures listeners $evd->on("eventName", function(Fwk\Events\Event $event) { // do some stuff }); // Class methods starting by "on[EventCamelCasedName]" can also be added as // listeners class MyListener { public function onEventName(Fwk\Events\Event $event) { // do some stuff } } $evd->addListener(new MyListener());
Removing Listeners
/* ... */ // this removes all listeners for a given event $evd->removeAllListeners("eventName"); // this removes a listener (callable) for a given event $evd->removeListener("eventName", array($listener, "onListenerMethod"));
Trigger Events
/* ... */ $event = new Fwk\Events\Event("eventName", array( "someData" => "someValue" )); $event->extraData = "extraValue"; // dispatch event $evd->notify($event);
Contributions / Community
- Issues on Github: https://github.com/fwk/Events/issues
- Follow Fwk on Twitter: @phpfwk
Legal
Fwk is licensed under the 3-clauses BSD license. Please read LICENSE for full details.
统计信息
- 总下载量: 571
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 5
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2012-05-22