Learn / Events, folds and gates
Events, folds and gates
Suppose your todo app syncs todos across devices while keeping filter ('all' or 'done') local to each device. You add a ClearedShown Message that checks model.filter inside update so it removes only the todos visible on screen.
On your laptop with filter: 'done', ClearedShown clears only completed items. On the server and on your phone, however, filter is local and not shared, so both replay ClearedShown with initial.filter ('all') and wipe out every todo in the list. When the synced state lands back on your laptop, your screen clears too.
That bug reveals the three rules behind shared state in Foldkit Plus:
- A replicated Message must carry the exact facts of what changed, never depend on unshared local state.
- State is whatever
updateleaves after folding Messages, starting frominitial. - Correctness is enforced at the server gate (
authorizeandlaws), not by trusting the client'sMessageunion.