bephp/observable

A observable trait

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

This package is not auto-updated.

Last update: 2024-11-15 19:42:15 UTC


README

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

A observable triat for PHP.

Installation

composer require bephp/observable

API Reference

on($event, $cb)

add event

off($event)

remove event

trigger()

trigger event

Example

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

this demo will get result:

hello lloyd!