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. The previous suppress flag is restored on exit, allowing the outermost set() call to trigger the actual dispatch cycle that processes all accumulated dirty slots.

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.