PHP Class PHPDaemon\PubSub\PubSub

Author: Zorin Vasily ([email protected])
Inheritance: use trait PHPDaemon\Traits\ClassWatchdog, use trait PHPDaemon\Traits\StaticObjectWatchdog
Datei anzeigen Open project: kakserpom/phpdaemon

Protected Properties

Property Type Description
$events Storage of events

Public Methods

Method Description
addEvent ( string $id, PubSubEvent $obj ) : void Adds event
eventExists ( string $id ) : boolean Is event exists?
pub ( string $id, mixed $data ) : boolean Publish
removeEvent ( string $id ) : void Removes event
sub ( string $id, object $obj, callable $cb ) : boolean Subcribe to event
unsub ( string $id, object $obj ) : boolean Unsubscribe object from event
unsubFromAll ( object $obj ) : boolean Unsubscribe object from all events

Method Details

addEvent() public method

Adds event
public addEvent ( string $id, PubSubEvent $obj ) : void
$id string Event ID
$obj PubSubEvent
return void

eventExists() public method

Is event exists?
public eventExists ( string $id ) : boolean
$id string Event ID
return boolean

pub() public method

Publish
public pub ( string $id, mixed $data ) : boolean
$id string Event ID
$data mixed Data
return boolean Success

removeEvent() public method

Removes event
public removeEvent ( string $id ) : void
$id string Event ID
return void

sub() public method

Subcribe to event
public sub ( string $id, object $obj, callable $cb ) : boolean
$id string Event ID
$obj object Subscriber
$cb callable Callback
return boolean Success

unsub() public method

Unsubscribe object from event
public unsub ( string $id, object $obj ) : boolean
$id string Event ID
$obj object Subscriber
return boolean Success

unsubFromAll() public method

Unsubscribe object from all events
public unsubFromAll ( object $obj ) : boolean
$obj object Subscriber
return boolean Success

Property Details

$events protected_oe property

Storage of events
protected $events