TanStackStore v0
Auto

__storeToDerived

Variable: __storeToDerived

ts
const __storeToDerived: WeakMap<Store<unknown, (cb) => unknown>, Set<Derived<unknown>>>;
const __storeToDerived: WeakMap<Store<unknown, (cb) => unknown>, Set<Derived<unknown>>>;

Defined in: scheduler.ts:19

This is here to solve the pyramid dependency problem where: A /
B C \ / D

Where we deeply traverse this tree, how do we avoid D being recomputed twice; once when B is updated, once when C is.

To solve this, we create linkedDeps that allows us to sync avoid writes to the state until all of the deps have been resolved.

This is a record of stores, because derived stores are not able to write values to, but stores are

Subscribe to Bytes

Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.

Bytes

No spam. Unsubscribe at any time.