Readonly
disposeDisposes the subscription, unsubscribing from the topic.
After disposal, the subscription will no longer receive messages.
Readonly
singleAwaits the next message published to the topic.
Throws an error if the subscription was disposed before a message was received.
Optional
returnOptional
value: anyOptional
throwOptional
e: any
Represents a lazily-initialized subscription to a Topic that is also an AsyncIterableIterator.
The subscription supports consuming published messages using
for await ... of
, awaiting a single message via single, and manual disposal via dispose. If an async iteration completes or ends early (e.g., viabreak
,return
, or an error), the subscription is automatically disposed.The subscription is created lazily: the first call to
next()
orsingle()
triggers the underlying registration. If the consumer never starts an iteration or never awaits a message, no subscription is created.