How would you keep a real-time UI correct after duplicate or out-of-order events?

Testing & architectureSystem designAbout 15 minutes

Understand the idea, explain it in your own words and use the rubric to find your next learning gap.

Local drafts · no account or AI calls
Sukoaa original

The idea behind the question

A transport delivering messages does not by itself define application ordering or recovery. Versioned records and a resynchronization protocol help the client identify stale events and missing state.

AN ILLUSTRATIVE EXAMPLE

The UI receives version five of a record and then version four after reconnecting. Applying both in arrival order rolls the display backward.

TRY A SMALL EXAMPLEJavaScript · standalone helper
// Complete record events with monotonic versions; not a resume protocol.
function apply(current, event) {
  if (current && event.version <= current.version) return current;
  return Object.freeze({ ...event });
}
let state = apply(null, { version: 5, value: 'current', deleted: false });
state = apply(state, { version: 4, value: 'stale', deleted: false });
console.log(state.version, state.value);
state = apply(state, { version: 6, value: null, deleted: true });
state = apply(state, { version: 5, value: 'late', deleted: false });
console.log(state.version, state.deleted);
Show expected output
5 current
6 true
Open JavaScript playground

Copy and paste to run in a separate tab. This example illustrates one concept; it is not a complete application or an automatically graded task.

A practical way to learn it

Write a pure version-merge helper and feed it repeated and reversed updates. Then specify which missing-event case requires authoritative resynchronization rather than guessing.

Open JavaScript playground

The related tool opens separately; your interview answer stays here. Written practice is self-guided, without automatic code grading.

Build an explanation you understand

  1. State what the concept does in plain language.
  2. Apply it to the example and make your assumptions explicit.
  3. Explain a trade-off, failure case and how you would test it.
  4. Distinguish your actual experience from a proposed approach.

Further reading

Further-reading links support learning; the reference is Sukoaa-authored, not an official employer answer key.