index.batch
batch<T>(fn): T
Executes a function within a synchronous batch context, deferring subscriber notifications until completion.
| Name | Description |
|---|---|
T |
The return type of the batch function. |
| Name | Type | Description |
|---|---|---|
fn |
() => T |
Synchronous callback function containing state mutations. |
T
The return value of fn.
Remarks
Within a batch block, all mutations across signals, objects, and collections accumulate without triggering
immediate downstream effects. Once the outermost batch function concludes, all unique affected subscribers
are notified in a single consolidated pass.
Nested calls to batch are automatically flattened.
Example