WildflowerJS Demos
Optimistic Tasks: data-query, write(), async computed, persist, rollback

Optimistic Tasks

Declarative writes and an async computed, against a deliberately slow server. v1.5+

tasks work left pts syncing…

The simulated server

Saves take about 1.4 seconds, so every change you make lands on screen first and syncs behind the gesture. The list is a live query over the server's rows; a write applies optimistically, and the server's answer confirms it or rolls it back.

Reload the page after a few changes. The list paints already filled, with no loading flash, and a revalidation confirms the rows behind the paint. That is persist: true on the query declaration doing the work, and only confirmed server truth is ever stored.

The server also answers estimates. Each task's size (S, M, L) weighs 1, 3, or 5 points, and the work left figure in the header is the server adding up the open tasks. An async computed requests a fresh estimate whenever the rows change, and the binding keeps the last figure while the new one is in flight, which is why it trails your edits by a beat.

Arming dooms the next write you start (never one already in flight) and slows that write to about five seconds, giving you time to overlap other writes before it lands.

See field-level rollback

  1. Arm Reject the next write.
  2. Tick a task done. That write is now in flight, doomed, and slowed to about five seconds so you have room.
  3. Before it settles, hit Rename on the same task and save a new title.
  4. Watch: the tick reverts when the server says no. The rename stays, because a different write owns that field, and its answer is still coming.

Add a task and watch its tmp- id flip to the server's id when the write confirms. Delete with the switch armed and the row comes back. Then reload the page and notice nothing flashes; the rows were already there.