watershed Collaborative data structures for Gleam

← Maps · SharedMap Sudoku cells

One board.
Three clients. One cell value.

The full Sudoku example layers SharedMap cell values with SharedOrSet pencil notes, SharedClaims givens, SharedCounter mistakes, and ephemeral signals for presence. This page isolates the cell layer: keys like r0c0 hold JSON digits, clears delete the key, and server-sequenced last-write-wins order makes concurrent edits converge.

SharedMap sudoku cells, live

Three watershed documents run the full runtime (wire codecs, pending queues, and all), compiled to JavaScript and running in your browser. They talk to one sluice: the in-memory server that ships in the library, standing in for floodgate with no backend. A cell edit renders optimistically and pushes an op the sluice sequences; delivery is explicit, so state propagates one stamped hop at a time. Local edits are drawn in magenta until the sequencer stamps them; server-sequenced state is ink.

Click any cell to cycle its digit, type 1–9 to write directly, or press Delete or Shift-click to clear. Arrow keys move across each board. Press Race the same cell and A, B, and C write different digits to the center cell, r4c4, at the same instant. The sluice sequences those writes FIFO, and every replica converges on the last sequenced value.

Client A

0 pending

81 keys · r0c0–r8c8 · values 1–9

Client B

0 pending

81 keys · r0c0–r8c8 · values 1–9

Client C

0 pending

81 keys · r0c0–r8c8 · values 1–9

Sequencer SN 0

    Converged all boards identical · nothing pending

    Latency and jitter affect simulated arrival order; animation speed changes playback only.