Primitives

Mutations

Optimistic projections, rollback, rebasing, and duplicate-submit protection.

The write returns authoritative data of the same type as initialData. A pure optimistic(confirmed, input) callback may project immediate UI state. Return new data; never mutate the confirmed object.

Snapshots include data (projected while pending), confirmed, input, error, and the same status/feedback flags as tasks. A failure restores the latest confirmed data. If projection throws, no write starts and the store reports the error.

Only one write may run per controller. Overlapping calls return busy; they do not queue or silently share an unrelated result. Independent controllers do not coordinate writes. Use server idempotency keys for protection across reloads, tabs, users, and processes.

reconcile(data) installs authoritative external data and reprojects any pending input onto it. If that projection throws, reconciliation throws and the previous snapshot is unchanged. A successful write's response becomes authoritative; applications that accept external updates concurrently must enforce server versions or reconcile again with the newest version.

There is no automatic retry, cancellation UI, or timeout for mutations. A disconnected client cannot know whether a server accepted a write. Local rollback is a display policy, not a server rollback. Offer a server-state check for uncertain outcomes. dispose() releases local resources and requests transport cancellation without making claims about server state.

View this page on GitHub ↗