AIDK API Reference / aidk/state / batch
Function: batch() ​
ts
function batch<T>(fn: () => T): T;Defined in: packages/core/src/state/signal.ts:131
Batch multiple signal updates together. Effects only run once after all updates complete.
Type Parameters ​
| Type Parameter |
|---|
T |
Parameters ​
| Parameter | Type |
|---|---|
fn | () => T |
Returns ​
T
Example ​
typescript
batch(() => {
count.set(1);
name.set('Alice');
// Effects run once here, not twice
});