Method
Subscription::getIterator
The messages, as they come; null after each $heartbeat seconds without one.
Description#
public Subscription::getIterator(): GeneratorThrows a WorkerStoppingException when the worker stops. A subscription made while
draining ends at once.
Return values#
Each message as published (a JSON message decoded; an object as a SealedObject), or null for a heartbeat Generator
Errors / Exceptions#
| Exception | When |
|---|---|
SubscriberLagException | When the next message arrived more than $maxLag seconds ago |
Examples#
foreach (Swerve::subscribe('chat') as $message) {
handle($message);
}