Skip to content
Source
Sign inSign up
TanStack/store
Open History to see the last commit

storetoderived.md

28 lines838 Bytes

1---
2id: __storeToDerived
3title: __storeToDerived
4---
5​
6<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
7​
8# Variable: \_\_storeToDerived
9​
10```ts
11const __storeToDerived: WeakMap<Store<unknown, (cb) => unknown>, Set<Derived<unknown, readonly any[]>>>;
12```
13​
14Defined in: [scheduler.ts:19](https://github.com/TanStack/store/blob/main/packages/store/src/scheduler.ts#L19)
15​
16This is here to solve the pyramid dependency problem where:
17 A
18 / \
19 B C
20 \ /
21 D
22​
23Where we deeply traverse this tree, how do we avoid D being recomputed twice; once when B is updated, once when C is.
24​
25To solve this, we create linkedDeps that allows us to sync avoid writes to the state until all of the deps have been
26resolved.
27​
28This is a record of stores, because derived stores are not able to write values to, but stores are