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

46 lines (45 loc) 2.17 kB
import { Patch } from '../../patch/Patch'; import { SerializedActionCall } from './actionSerialization'; /** * Serialized action call with model ID overrides. * Can be generated with `applySerializedActionAndTrackNewModelIds`. * To be applied with `applySerializedActionAndSyncNewModelIds`. */ export interface SerializedActionCallWithModelIdOverrides extends SerializedActionCall { /** * Model Id overrides to be applied at the end of applying the action. */ readonly modelIdOverrides: ReadonlyArray<Patch>; } /** * Applies (runs) a serialized action over a target object. * In this mode newly generated / modified model IDs will be tracked * so they can be later synchronized when applying it on another machine * via `applySerializedActionAndSyncNewModelIds`. * This means this method is usually used on the server side. * * If you intend to apply non-serialized actions check `applyAction` instead. * * @param subtreeRoot Subtree root target object to run the action over. * @param call The serialized action, usually as coming from the server/client. * @returns The return value of the action, if any, plus a new serialized action * with model overrides. */ export declare function applySerializedActionAndTrackNewModelIds<TRet = any>(subtreeRoot: object, call: SerializedActionCall): { returnValue: TRet; serializedActionCall: SerializedActionCallWithModelIdOverrides; }; /** * Applies (runs) a serialized action over a target object. * In this mode newly generated / modified model IDs previously tracked * by `applySerializedActionAndTrackNewModelIds` will be synchronized after * the action is applied. * This means this method is usually used on the client side. * * If you intend to apply non-serialized actions check `applyAction` instead. * * @param subtreeRoot Subtree root target object to run the action over. * @param call The serialized action, usually as coming from the server/client. * @returns The return value of the action, if any. */ export declare function applySerializedActionAndSyncNewModelIds<TRet = any>(subtreeRoot: object, call: SerializedActionCallWithModelIdOverrides): TRet;