Dev.Lib
arrow_backBack to Blogs
LEVEL_088.10June 27, 20261 min read

Deterministic UI under async

Concurrency & Streams

Async completions arrive out of order — UI must show consistent state (request tokens, latest-wins, merge).

Summary

Async completions arrive out of order — UI must show consistent state (request tokens, latest-wins, merge). Skeleton → content transitions shouldn't flash wrong user's data. Combine with 4.5 Race conditions and 4.9 Deterministic rendering.


Code example

let requestSeq = 0;

async function loadUser(id) {
  const seq = ++requestSeq;
  const user = await fetchUser(id);
  if (seq !== requestSeq) return; // stale response
  setUser(user);
}

Key points

  • Async completions arrive out of order — UI must show consistent state (request tokens, latest-wins, merge).
  • Skeleton → content transitions shouldn't flash wrong user's data.
  • Combine with 4.5 Race conditions and 4.9 Deterministic rendering.

Further reading

Related concepts