Skip to content

API reference > @kontsedal/olas-cross-tab > SetDataMessage

SetDataMessage type ​

What a tab posts when the app writes a synced query's data outside a fetch or hydration. A receiving tab applies data to the same entry, as whatsource says it is:

  • 'write' and 'replace' are canonical. The receiver writes the server truth, server.data when the sender's data held a guess and data otherwise, as a patch or as a replace that supersedes its own fetch. - 'optimistic' is a guess. The receiver shows data as a guess of its own, which leaves its stale clock alone and waits for the sender's rollback or commit. - 'rollback' removes that guess. server present means the sender still shows other guesses, and the receiver shows data as one. - 'commit' makes data the receiver's data as a commit does: the guess is committed, and the stale clock is left alone.

Signature:

typescript
type SetDataMessage = {
  v: typeof PROTOCOL_VERSION;
  type: 'setData';
  sourceId: string;
  msgId: number;
  queryId: string;
  keyArgs: readonly unknown[];
  data: unknown;
  pageParams?: readonly unknown[];
  source?: RelayedSource;
  server?: {
    data: unknown;
    pageParams?: readonly unknown[];
  };
};

References: PROTOCOL_VERSION, RelayedSource

Released under the MIT License.