bephp/observable

一个可观察的特质

v0.1 2016-04-15 15:02 UTC

This package is not auto-updated.

Last update: 2024-09-20 18:59:19 UTC


README

Build Status Coverage Status Latest Stable Version Total Downloads Latest Unstable Version License

PHP 的一个可观察特质。

安装

composer require bephp/observable

API 参考

on($event, $cb)

添加事件

off($event)

移除事件

trigger()

触发事件

示例

class A{
    use Observable;
}
$a = new A();
$a->on('hello', function($name){
    echo 'hello ', $name, '!';
});
$a->trigger('hello', 'lloyd');

这个示例将会得到结果

hello lloyd!