mobx-keystone
Version:
A MobX powered state management solution based on data trees with first class support for TypeScript, snapshots, patches and much more
23 lines (22 loc) • 985 B
TypeScript
import { AnyType, TypeToData } from '../types/schemas';
import { SnapshotOutOf } from './SnapshotOf';
/**
* Retrieves an immutable snapshot for a data structure.
* Since returned snapshots are immutable they will respect shallow equality, this is,
* if no changes are made then the snapshot will be kept the same.
*
* @template T Object type.
* @param nodeOrPrimitive Data structure, including primtives.
* @returns The snapshot.
*/
export declare function getSnapshot<T extends AnyType>(type: T, nodeOrPrimitive: TypeToData<T>): SnapshotOutOf<TypeToData<T>>;
/**
* Retrieves an immutable snapshot for a data structure.
* Since returned snapshots are immutable they will respect shallow equality, this is,
* if no changes are made then the snapshot will be kept the same.
*
* @template T Object type.
* @param nodeOrPrimitive Data structure, including primtives.
* @returns The snapshot.
*/
export declare function getSnapshot<T>(nodeOrPrimitive: T): SnapshotOutOf<T>;