diff options
| author | Adam Malczewski <[email protected]> | 2026-06-01 10:41:47 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-06-01 10:41:47 +0900 |
| commit | ecce93d9dfecd0c61c0f8c3fa8024f60359e1f17 (patch) | |
| tree | 81ea46a48b2c67ec3bba74102fd80334c0e63409 /packages/api/src | |
| parent | dbabca525ee70126b3d2264dad88c0dcca630b83 (diff) | |
| download | dispatch-ecce93d9dfecd0c61c0f8c3fa8024f60359e1f17.tar.gz dispatch-ecce93d9dfecd0c61c0f8c3fa8024f60359e1f17.zip | |
feat(frontend): SnapshotSequencer — reusable 'most-recent request wins' race guard
Tiny, dependency-free class for the common pattern where a component
fans out multiple HTTP calls that each return a full snapshot of
shared state, and applying an older snapshot would clobber a newer
one. begin() tags a new request, accept(seq) decides whether to
apply the response.
Pulled out as its own module (rather than inlined in ClaudeReset)
because the next consumer of this pattern shouldn't have to
re-derive it. The contract is small enough to test exhaustively
in isolation:
- accepts the first response unconditionally
- accepts responses in send order
- rejects an older response that arrives AFTER a newer one (the
core race that motivated this)
- rejects ALL stragglers once a newer one wins
- handles the initial-load vs first-click race
- equal seq is idempotent accept (defensive)
- begin() seqs are monotonic and unique
- state inspector reflects the watermark
8 tests, all green. No Svelte dependency — usable from any TS file.
Diffstat (limited to 'packages/api/src')
0 files changed, 0 insertions, 0 deletions
