Method
SubscribersInterface::subscribe
Creates a subscription that receives the messages published after this call.
Description#
public SubscribersInterface::subscribe(): SubscriberInterfaceReturn values#
The subscription SubscriberInterface
Examples#
phasync::run(function () {
phasync::publisher($subscribers, $publisher);
$subscription = $subscribers->subscribe();
phasync::go(function () use ($subscription) {
foreach ($subscription as $event) {
echo "got $event\n";
}
});
$publisher->write('deployed');
$publisher->close();
});See also#
phasync::publisherCreates a publisher: what is written to$publisheris delivered to every subscription of$subscribers.