Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

Sub

import type { Sub } from "https://raw.githubusercontent.com/nats-io/nats.deno/v1.27.0/nats-base-client/internal_mod.ts";

Basic interface to a Subscription type

interface Sub <T> extends AsyncIterable<T> {
closed: Promise<void>;
callback(err: NatsError | null, msg: Msg): void;
drain(): Promise<void>;
getID(): number;
getMax(): number | undefined;
getPending(): number;
getProcessed(): number;
getReceived(): number;
getSubject(): string;
isClosed(): boolean;
isDraining(): boolean;
unsubscribe(max?: number): void;
}

§Type Parameters

§Extends

§
AsyncIterable<T>
[src]

§Properties

§
closed: Promise<void>
[src]

A promise that resolves when the subscription closes

§Methods

§
callback(err: NatsError | null, msg: Msg): void
[src]
§
drain(): Promise<void>
[src]

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.

§
getID(): number
[src]
§
getMax(): number | undefined
[src]

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

§
getPending(): number
[src]

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

§
getProcessed(): number
[src]

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

§
getReceived(): number
[src]

Returns the number of messages received by the subscription.

§
getSubject(): string
[src]

Returns the subject that was used to create the subscription.

§
isClosed(): boolean
[src]

Returns true if the subscription is closed.

§
isDraining(): boolean
[src]

Returns true if the subscription is draining.

§
unsubscribe(max?: number): void
[src]

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.

@param max