@nats-io/nats-core
    Preparing search index...

    Interface Subscription

    Basic interface to a Subscription type

    interface Subscription {
        closed: Promise<void | Error>;
        "[asyncIterator]"(): AsyncIterator<Msg, any, any>;
        drain(): Promise<void>;
        getMax(): number;
        getPending(): number;
        getProcessed(): number;
        getReceived(): number;
        getSubject(): string;
        isClosed(): boolean;
        isDraining(): boolean;
        unsubscribe(max?: number): void;
    }

    Hierarchy

    • AsyncIterable<Msg>
      • Subscription
    Index

    Properties

    closed: Promise<void | Error>

    A promise that resolves when the subscription closes. If the promise resolves to an error, the subscription was closed because of an error typically a permissions error. Note that this promise doesn't reject, but rather resolves to void (no error) or an Error

    Methods

    • Returns AsyncIterator<Msg, any, any>

    • 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>

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

      Returns number

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

      Returns number

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

      Returns number

    • Returns the number of messages received by the subscription.

      Returns number

    • Returns the subject that was used to create the subscription.

      Returns string

    • Returns true if the subscription is closed.

      Returns boolean

    • Returns true if the subscription is draining.

      Returns boolean

    • 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

      • Optionalmax: number

      Returns void