const data = proxy("before");
$({text: data});
console.log(1, document.body.innerHTML); // before
// Make an update that should cause the DOM to change.
data.value = "after";
// Normally, the DOM update would happen after a timeout.
// But this causes an immediate update:
runQueue();
console.log(2, document.body.innerHTML); // after
Forces the immediate and synchronous execution of all pending reactive updates.
Normally, changes to observed data sources (like proxied objects or arrays) are processed asynchronously in a batch after a brief timeout (0ms). This function allows you to bypass the timeout and process the update queue immediately.
This can be useful in specific scenarios where you need the DOM to be updated synchronously.
This function is re-entrant, meaning it is safe to call
runQueue
from within a function that is itself being executed as part of an update cycle triggered by a previous (or the same)runQueue
call.