UNPKG

921 BTypeScriptView Raw
1import { IObjectDidChange, IArrayDidChange, IMapDidChange } from "mobx";
2import { IDisposer } from "./utils";
3declare type IChange = IObjectDidChange | IArrayDidChange | IMapDidChange;
4/**
5 * Given an object, deeply observes the given object.
6 * It is like `observe` from mobx, but applied recursively, including all future children.
7 *
8 * Note that the given object cannot ever contain cycles and should be a tree.
9 *
10 * As benefit: path and root will be provided in the callback, so the signature of the listener is
11 * (change, path, root) => void
12 *
13 * The returned disposer can be invoked to clean up the listener
14 *
15 * deepObserve cannot be used on computed values.
16 *
17 * @example
18 * const disposer = deepObserve(target, (change, path) => {
19 * console.dir(change)
20 * })
21 */
22export declare function deepObserve<T = any>(target: T, listener: (change: IChange, path: string, root: T) => void): IDisposer;
23export {};