Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/natsws/src/mod.ts>Sub

WebSocket NATS
Latest
interface Sub
implements AsyncIterable<T>
import { type Sub } from "https://deno.land/x/natsws@v1.28.0/src/mod.ts";

Basic interface to a Subscription type

Properties

closed: Promise<void>

A promise that resolves when the subscription closes

Methods

unsubscribe(max?: number): 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.

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.

isDraining(): boolean

Returns true if the subscription is draining.

isClosed(): boolean

Returns true if the subscription is closed.

getSubject(): string

Returns the subject that was used to create the subscription.

getReceived(): number

Returns the number of messages received by the subscription.

getProcessed(): number

Returns the number of messages that have been processed by the subscription.

getPending(): number

Returns the number of messages that are pending processing. Note that this is method is only valid for iterators.

getMax(): number | undefined

Return the max number of messages before the subscription will unsubscribe.