[]previous and next page

Scheduler and timing

Exactly when signal and store writes reach effects and the DOM, in which order effects run, and what stops an effect loop.

For agentsUpdated

ShadowJS separates two things that other frameworks fuse: committing a write and running the effects that depend on it.

Moment What happens
set(value) returns The value is committed. Every read, including a useMemo, already sees it (read-your-writes).
The write is not inside a batch, an event handler or flushSync Effects wait for one microtask, scheduled by the first write.
batch(fn) ends (outermost) Pending effects run synchronously, before batch returns.
A framework-dispatched event handler returns Same as batch: the DOM is current when the handler returns.
flushSync(fn?) Runs fn in a batch, then drains every pending effect before returning.

This is decision ADR-007. Signal writes and store writes follow the same rule: one setStore(...) call behaves like one set().