Skip to content

StateClient

App-scoped shared state across the live frames of ONE app — the top-level app frame plus its modal / embedded-surface frames — brokered by the shell (so it is observable and origin-independent, unlike a raw same-origin BroadcastChannel). The model is single-writer, many-readers: a namespace has at most one writer; readers never write, so there is no lost-update. State is keyed by (appId, namespace) and never crosses apps. Every snapshot must be structured-clone serializable.

get<S>(namespace): S | undefined;

The last-known snapshot for a namespace, or undefined before the first sync.

S = unknown

string

S | undefined


publish<S>(namespace, initial): StateWriter<S>;

Claim the (single) writer slot for a namespace and seed its snapshot; returns a StateWriter.

S = unknown

string

S

StateWriter<S>


subscribe<S>(namespace, handler): () => void;

Observe a namespace: the current snapshot (if one exists) and every later update. Read-only; returns an unsubscribe.

S = unknown

string

(snapshot, rev) => void

() => void