Run fn once immediately, tracking every signal it reads, and re-run
it whenever any of those change. Dependencies are re-tracked on every run,
so conditional reads narrow or widen them dynamically.
By default re-runs are batched: all writes in the same tick coalesce into
a single re-run on the next microtask, observing the final state. Pass
{ sync: true } to re-run synchronously at each write instead.
An effect that writes to its own dependencies re-runs until it stabilizes.
If it doesn't stabilize within a bounded number of runs, the effect is
disposed and an error is thrown (for a default effect this surfaces as an
uncaught exception from the microtask flush, since there is no caller to
receive it).
Effects stay registered until disposed — they are never garbage-collected
on their own. Avoid creating effects inside other effects or inside
computed functions: each run of the outer computation would register a
fresh inner effect.
Run
fnonce immediately, tracking every signal it reads, and re-run it whenever any of those change. Dependencies are re-tracked on every run, so conditional reads narrow or widen them dynamically.By default re-runs are batched: all writes in the same tick coalesce into a single re-run on the next microtask, observing the final state. Pass
{ sync: true }to re-run synchronously at each write instead.An effect that writes to its own dependencies re-runs until it stabilizes. If it doesn't stabilize within a bounded number of runs, the effect is disposed and an error is thrown (for a default effect this surfaces as an uncaught exception from the microtask flush, since there is no caller to receive it).
Effects stay registered until disposed — they are never garbage-collected on their own. Avoid creating effects inside other effects or inside computed functions: each run of the outer computation would register a fresh inner effect.