Files
med-notes/.pnpm-store/v10/files/77/5e93031d02daa2424f58871fbb5de2931b8ff0ca5bc9c9d73201c5b3b0d83e06b929091c761af3cf6caee986e2aa4f6815f8c39b8dd3947be48a28c3be4c08
2025-05-09 05:30:08 +02:00

28 lines
1.1 KiB
Plaintext

import { Derived } from './derived.js';
import { Store } from './store.js';
/**
* 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
*/
export declare const __storeToDerived: WeakMap<Store<unknown, (cb: unknown) => unknown>, Set<Derived<unknown, readonly any[]>>>;
export declare const __derivedToStore: WeakMap<Derived<unknown, readonly any[]>, Set<Store<unknown, (cb: unknown) => unknown>>>;
export declare const __depsThatHaveWrittenThisTick: {
current: Array<Derived<unknown> | Store<unknown>>;
};
/**
* @private only to be called from `Store` on write
*/
export declare function __flush(store: Store<unknown>): void;
export declare function batch(fn: () => void): void;