mobx-bonsai
Version:
A fast lightweight alternative to MobX-State-Tree + Y.js two-way binding
17 lines (16 loc) • 662 B
TypeScript
import { IArrayDidChange, IObjectDidChange } from 'mobx';
import { UndoableChange } from './types';
/**
* MobX change events from onDeepChange.
*/
export type NodeChange = IObjectDidChange | IArrayDidChange;
/**
* Converts a MobX change event to an UndoableChange.
* Calculates the path from the tracked root to the changed object/array.
* Values are stored using getSnapshot for immutability.
*
* @param change - The MobX change event
* @param rootNode - The root node being tracked by the UndoManager
* @returns An UndoableChange representing the change
*/
export declare function captureChange(change: NodeChange, rootNode: object): UndoableChange;