mobx-bonsai
Version:
A fast lightweight alternative to MobX-State-Tree + Y.js two-way binding
20 lines (19 loc) • 701 B
TypeScript
/**
* Gets the cached snapshot for a node without creating one if it doesn't exist.
* Returns undefined if no snapshot has been cached yet.
* @internal
*/
export declare function getCachedSnapshot<T extends object>(node: T): T | undefined;
export declare const invalidateSnapshotTreeToRoot: (node: object) => void;
/**
* Returns a stable snapshot of a node.
*
* This function computes and caches a snapshot of the given node.
* It preserves referential integrity by reusing snapshots for unchanged sub-parts.
*
* If not a node it will throw.
*
* @param node - The node to snapshot.
* @returns A snapshot of the node.
*/
export declare function getSnapshot<T extends object>(node: T): T;