flush
Runs every queued observer and binding update now, instead of at the end of the microtask.
flush(): voidimport { flush } from "https://cdn.jsdelivr.net/npm/@realmorg/realm@alpha/dist/index.js";
state.items.push(item);
flush();
// the DOM shows the new item hereBehaviour
- Updates run in rounds until nothing is queued. After 100 rounds, the queue is cleared and
Update loop detected: an observer keeps changing state it depends on.is reported. - Calling it with nothing queued does nothing.
- Inside a component script, prefer
await tick(), which waits a microtask and then flushes.flushis not one of the script helpers. - Fetch attributes call
flush()before building a request, so a request sees state changed earlier in the same event.