Sanity Library Reference Docs
    Preparing search index...

    Interface MessageBusConnection<TTopics>

    A message bus connection that can be torn down independently of its siblings.

    interface MessageBusConnection<TTopics = MessageBusTopics> {
        appId: string;
        disconnect(): void;
        emit<K extends string | number | symbol>(
            type: K,
            ...rest: PayloadOf<K, TTopics> extends void
                ? [payload?: void, options?: MessageBusEmitOptions]
                : [payload: PayloadOf<K, TTopics>, options?: MessageBusEmitOptions],
        ): MessageBusEmitResult<ReplyOf<K, TTopics>>;
        query<K extends string | number | symbol>(
            type: K,
            options?: MessageBusQueryOptions,
        ): Promise<ValueOf<K, TTopics>>;
        subscribe<K extends string | number | symbol>(
            type: K,
            handler: (
                message: MessageBusMessage<
                    PayloadOf<K, TTopics>,
                    ReplyOf<K, TTopics>,
                    K,
                >,
            ) => void,
            options?: MessageBusAbortOptions,
        ): void;
        subscribe<K extends string | number | symbol>(
            type: K,
            handler: (value: ValueOf<K, TTopics>) => void,
            options?: MessageBusAbortOptions,
        ): void;
        subscribe<K extends string | number | symbol>(
            type: K,
        ): MessageBusStateSource<ValueOf<K, TTopics>>;
        subscribe<K extends string | number | symbol>(
            type: K,
        ): Observable<PayloadOf<K, TTopics>>;
    }

    Type Parameters

    • TTopics = MessageBusTopics

    Hierarchy (View Summary)

    Index

    Properties

    Methods

    Properties

    appId: string

    The application this connection belongs to.

    Methods

    • Tears down this connection: pending requests reject ABORTED, subscriptions complete, and later emit, query, and subscribe calls fail with ABORTED. Siblings and the shared bus are untouched.

      Returns void