Menu

1 / 2

3 write scenarios your Angular app probably gets wrong

DEV Community: angular·Erwan Raulo·1 day ago
#jMNmthFX
#devtoangular#devto#dev#queue#mutation
Long article (1092 words) — no AI summary yet.
Reading 0:00
15s threshold

The user types hello .

Five PUT requests leave but the one carrying hel arrives last.

The server stores hel . The UI shows Saved ✓ .

No error, no log: a lost update , an anomaly the database literature formalized back in 1995 [1]. Your frontend can cause one without any help from the database.

Autosave is only the first of three write bugs this article covers, each with its fix, using @ngsignal/mutation ( introduced here ). Each one has a live page in the demo .

1. Autosave: send only the latest version

Parallel PUTs can be processed in any order. A FIFO queue fixes the order but sends every outdated version. Autosave needs something in between: finish the request in flight, then send only the latest version.

readonly save = httpMutation ( ( doc : Doc ) => ( { method : 'PUT' , url : `/api/docs/${doc.id}` , body : doc } ) , { concurrency : { mode : 'queue-latest' , debounce : 500 } } , ) ;

Enter fullscreen mode

Exit fullscreen mode

At most two calls exist at once: one in flight and one waiting.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.