Skip to main content

batch

Function batch 

Source
pub fn batch<F, R>(callback: F) -> R
where F: FnOnce() -> R,
Expand description

Batches signal updates within a closure, deferring DOM dispatch until the outermost batch completes.

Sets SUPPRESS_SCHEDULE to true so that any Signal::set() calls inside the closure mark their dependents dirty precisely but do not queue a microtask dispatch. When the outermost batch completes, a single dispatch is scheduled if any dirty slots were accumulated during the batch, ensuring that all pending updates are processed.

Unlike the legacy full-broadcast approach, this uses precise dependency tracking: only the dynamic nodes that actually depend on the changed signals are marked dirty and re-rendered.

§Arguments

  • FnOnce() -> R - The closure to execute with batched updates.

§Returns

  • R - The result of the closure execution.