Sanity Library Reference Docs
    Preparing search index...

    Interface MessageBusClient

    The host's handle to one connection: who it is, when it closes, and where to write its state.

    interface MessageBusClient {
        appId: string;
        closed: AbortSignal;
        moduleId: string;
        emit<K extends StateTopic>(type: K, value: ValueOf<K>): void;
        reject<K extends StateTopic>(type: K, message?: string): void;
    }
    Index

    Properties

    Methods

    Properties

    appId: string

    The application the connection belongs to.

    closed: AbortSignal

    Aborts when the connection disconnects. Drop per-client state here.

    moduleId: string

    The federation module id of the connection. Equals appId when the host supplied none.

    Methods

    • Rejects a state topic for this connection: its pending and later MessageBus.query calls reject with a MessageBusError whose code is 'REFUSED', until the host next writes a value with MessageBusClient.emit, which clears the rejection.

      Type Parameters

      Parameters

      • type: K
      • Optionalmessage: string

      Returns void

      A rejected promise cannot be un-rejected and an errored subject cannot resume, so the rejection is tracked per connection alongside the topic's subject rather than by erroring it: query consults it before awaiting, and MessageBus.subscribe and the topic's MessageBusStateSource stay silent (they never error) until a value is written. Ignored once the connection has closed, the same as MessageBusClient.emit.