Sub
@wuespace/telestion / nats / Sub
Basic interface to a Subscription type
Extends¶
AsyncIterable
<T
>
Type parameters¶
• T
Properties¶
closed¶
closed:
Promise
<void
>
A promise that resolves when the subscription closes
Methods¶
[asyncIterator]
()¶
[asyncIterator]():
AsyncIterator
<T
,any
,undefined
>
Returns¶
AsyncIterator
<T
, any
, undefined
>
Inherited from¶
AsyncIterable.[asyncIterator]
drain()¶
drain():
Promise
<void
>
Drain the subscription, closing it after processing all messages currently in flight for the client. Returns a promise that resolves when the subscription finished draining.
Returns¶
Promise
<void
>
getMax()¶
getMax():
undefined
|number
Return the max number of messages before the subscription will unsubscribe.
Returns¶
undefined
| number
getPending()¶
getPending():
number
Returns the number of messages that are pending processing. Note that this is method is only valid for iterators.
Returns¶
number
getProcessed()¶
getProcessed():
number
Returns the number of messages that have been processed by the subscription.
Returns¶
number
getReceived()¶
getReceived():
number
Returns the number of messages received by the subscription.
Returns¶
number
getSubject()¶
getSubject():
string
Returns the subject that was used to create the subscription.
Returns¶
string
isClosed()¶
isClosed():
boolean
Returns true if the subscription is closed.
Returns¶
boolean
isDraining()¶
isDraining():
boolean
Returns true if the subscription is draining.
Returns¶
boolean
unsubscribe()¶
unsubscribe(
max
?):void
Stop the subscription from receiving messages. You can optionally specify that the subscription should stop after the specified number of messages have been received. Note this count is since the lifetime of the subscription.
Parameters¶
• max?: number
Returns¶
void