PHPDaemon\PubSub\PubSubEvent::sub PHP Method

sub() public method

Subscribe
public sub ( object $obj, callable $cb ) : this
$obj object Subcriber object
$cb callable Callback
return this
    public function sub($obj, $cb)
    {
        $act = $this->count() === 0;
        $this->attach($obj, $cb);
        if ($act) {
            if (($func = $this->actCb) !== null) {
                $func($this);
            }
        }
        return $this;
    }