diff --git a/docs/reference/functions/batch.md b/docs/reference/functions/batch.md index 36bfffd..c5be233 100644 --- a/docs/reference/functions/batch.md +++ b/docs/reference/functions/batch.md @@ -19,4 +19,4 @@ function batch(fn): void ## Defined in -[scheduler.ts:120](https://github.com/TanStack/store/blob/main/packages/store/src/scheduler.ts#L120) +[scheduler.ts:129](https://github.com/TanStack/store/blob/main/packages/store/src/scheduler.ts#L129) diff --git a/packages/store/src/scheduler.ts b/packages/store/src/scheduler.ts index 87eb19a..2834d0d 100644 --- a/packages/store/src/scheduler.ts +++ b/packages/store/src/scheduler.ts @@ -37,26 +37,26 @@ function __flush_internals(relatedVals: Set>) { // First sort deriveds by dependency order const sorted = Array.from(relatedVals).sort((a, b) => { // If a depends on b, b should go first - if (a instanceof Derived && a.options.deps.includes(b)) return 1; + if (a instanceof Derived && a.options.deps.includes(b)) return 1 // If b depends on a, a should go first - if (b instanceof Derived && b.options.deps.includes(a)) return -1; - return 0; - }); + if (b instanceof Derived && b.options.deps.includes(a)) return -1 + return 0 + }) for (const derived of sorted) { if (__depsThatHaveWrittenThisTick.current.includes(derived)) { - continue; + continue } - __depsThatHaveWrittenThisTick.current.push(derived); - derived.recompute(); + __depsThatHaveWrittenThisTick.current.push(derived) + derived.recompute() - const stores = __derivedToStore.get(derived); + const stores = __derivedToStore.get(derived) if (stores) { for (const store of stores) { - const relatedLinkedDerivedVals = __storeToDerived.get(store); - if (!relatedLinkedDerivedVals) continue; - __flush_internals(relatedLinkedDerivedVals); + const relatedLinkedDerivedVals = __storeToDerived.get(store) + if (!relatedLinkedDerivedVals) continue + __flush_internals(relatedLinkedDerivedVals) } } }