@lppedd/message-bus - v0.2.0
    Preparing search index...

    Interface LazyAsyncSubscription<T>

    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., via break, return, or an error), the subscription is automatically disposed.

    The subscription is created lazily: the first call to next() or single() triggers the underlying registration. If the consumer never starts an iteration or never awaits a message, no subscription is created.

    interface LazyAsyncSubscription<T = unknown> {
        dispose: () => void;
        single: () => Promise<T>;
        "[asyncIterator]"(): AsyncIterableIterator<T, any, any>;
        next(...__namedParameters: [] | [any]): Promise<IteratorResult<T, any>>;
        return(value?: any): Promise<IteratorResult<T, any>>;
        throw(e?: any): Promise<IteratorResult<T, any>>;
    }

    Type Parameters

    • T = unknown

    Hierarchy (View Summary)

    Index

    Properties

    dispose: () => void

    Disposes the subscription, unsubscribing from the topic.

    After disposal, the subscription will no longer receive messages.

    single: () => Promise<T>

    Awaits the next message published to the topic.

    Throws an error if the subscription was disposed before a message was received.

    Methods

    • Returns AsyncIterableIterator<T, any, any>

    • Parameters

      • ...__namedParameters: [] | [any]

      Returns Promise<IteratorResult<T, any>>

    • Parameters

      • Optionalvalue: any

      Returns Promise<IteratorResult<T, any>>

    • Parameters

      • Optionale: any

      Returns Promise<IteratorResult<T, any>>