Skip to main content

batch()

batch<T>(fn): T

Defined in: js-api/src/u2core/signals-core.ts:95

Combine multiple value updates into one "commit" at the end of the provided callback.

Batches can be nested and changes are only flushed once the outermost batch callback completes.

Accessing a signal that has been modified within a batch will reflect its updated value.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
fn() => TThe callback function.

Returns

T

The value returned by the callback.