UNPKG

mobx-keystone-mindreframer

Version:

A MobX powered state management solution based on data trees with first class support for Typescript, snapshots, patches and much more

19 lines (18 loc) 733 B
import type { SnapshotOutOf } from "./SnapshotOf"; /** * Listener function for onSnapshot. */ export declare type OnSnapshotListener<T> = (sn: SnapshotOutOf<T>, prevSn: SnapshotOutOf<T>) => void; /** * Disposer function for onSnapshot. */ export declare type OnSnapshotDisposer = () => void; /** * Adds a reaction that will trigger every time an snapshot changes. * * @typeparam T Object type. * @param nodeOrFn Object to get the snapshot from or a function to get it. * @param listener Function that will be triggered when the snapshot changes. * @returns A disposer. */ export declare function onSnapshot<T extends object>(nodeOrFn: T | (() => T), listener: OnSnapshotListener<T>): OnSnapshotDisposer;