Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 4x 4x 6x | import { hub } from '../hub'
import type { Action } from '../../RuneHub'
/**
* Batches multiple updates together for efficient processing.
* All updates within the action are queued and processed together after completion.
* This prevents unnecessary intermediate updates and improves performance.
* @param action - The action containing multiple updates to batch
* @example
* ```ts
* const a = () => 0
* const b = () => 0
* const sum = () => get(a) + get(b)
* const log = () => console.log(get(sum))
*
* on(log)
* // logs: 0
*
* batch(() => {
* set(a, 400)
* set(b, 20)
* })
* // logs: 420
* ```
*/
export function batch (action: Action): void {
hub().batch(action)
}
|