Interface
SubscribersInterface
The subscription point of a publisher: each call to subscribe() makes a reader that receives every later message.
Introduction#
Iterating over it reads the messages of a new subscription.
Class synopsis#
interface SubscribersInterface extends \IteratorAggregate, \Traversable {
/* Methods */
public SubscribersInterface::subscribe(): SubscriberInterface
}Methods#
| Method | Description |
|---|---|
subscribe | Creates a subscription that receives the messages published after this call. |
Examples#
phasync::run(function () {
phasync::publisher($subscribers, $publisher);
$subscription = $subscribers->subscribe();
$publisher->write('first');
$publisher->close();
echo $subscription->read(); // first
});See also#
phasync::publisherCreates a publisher: what is written to$publisheris delivered to every subscription of$subscribers.SubscriberInterfaceA subscription to a publisher: a reading end that receives every message published after it was made.