UNPKG

mobx-keystone

Version:

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

26 lines (25 loc) 912 B
/** * Mode for the `walkTree` method. */ export declare enum WalkTreeMode { /** * The walk will be done parent (roots) first, then children. */ ParentFirst = "parentFirst", /** * The walk will be done children (leafs) first, then parents. */ ChildrenFirst = "childrenFirst" } /** * Walks a tree, running the predicate function for each node. * If the predicate function returns something other than undefined, * then the walk will be stopped and the function will return the returned value. * * @template T Returned object type, defaults to void. * @param root Subtree root object. * @param visit Function that will be run for each node of the tree. * @param mode Mode to walk the tree, as defined in `WalkTreeMode`. * @returns */ export declare function walkTree<T = void>(root: object, visit: (node: object) => T | undefined, mode: WalkTreeMode): T | undefined;