Sanity Library Reference Docs
    Preparing search index...

    Interface MessageBusConnection

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

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

    Hierarchy (View Summary)

    Index

    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