Rename, then delete
Two different mutations writing the same todo: a rename, then a delete. Given the same mutationQueue(), the delete waits for the rename, so the rename never reaches a deleted todo. Source
Edit the title, then click Delete. A rename takes 1.2 s, a delete 0.3 s (artificial delays).
Two mutations, no shared queue
- rename: status() / error()
- idle
- remove: status()
- idle
- server
- Buy milk
The DELETE lands first: the PATCH fails with a 404.
Server
- Nothing yet.
Same mutationQueue()
- rename: status() / error()
- idle
- remove: status()
- idle
- server
- Buy milk
The DELETE leaves once the PATCH has settled: both succeed, in order.
Server
- Nothing yet.
private readonly todoWrites = mutationQueue();
protected readonly renameQueued = mutation<string, string, Error>({
concurrency: this.todoWrites,
mutationFn: (title, abortSignal) => this.queuedServer.rename(title, abortSignal),
});
protected readonly removeQueued = mutation<void, void, Error>({
concurrency: this.todoWrites,
mutationFn: (_input, abortSignal) => this.queuedServer.remove(abortSignal),
});