MCPcopy Create free account
hub / github.com/Effect-TS/effect / batch

Function batch

packages/effect/src/unstable/reactivity/AtomRegistry.ts:1095–1117  ·  view source on GitHub ↗
(f: () => void)

Source from the content-addressed store, hash-verified

1093
1094/** @internal */
1095export function batch(f: () => void): void {
1096 batchState.phase = BatchPhase.collect
1097 batchState.depth++
1098 try {
1099 f()
1100 if (batchState.depth === 1) {
1101 for (let i = 0; i < batchState.stale.length; i++) {
1102 batchRebuildNode(batchState.stale[i])
1103 }
1104 batchState.phase = BatchPhase.commit
1105 for (const node of batchState.notify) {
1106 node.notify()
1107 }
1108 batchState.notify.clear()
1109 }
1110 } finally {
1111 batchState.depth--
1112 if (batchState.depth === 0) {
1113 batchState.phase = BatchPhase.disabled
1114 batchState.stale = []
1115 }
1116 }
1117}
1118
1119function batchRebuildNode(node: NodeImpl<any>) {
1120 if (node.state === NodeState.valid) {

Callers 2

Atom.tsFile · 0.70
writeFunction · 0.70

Calls 4

batchRebuildNodeFunction · 0.85
clearMethod · 0.80
fFunction · 0.50
notifyMethod · 0.45

Tested by

no test coverage detected