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
47 lines (46 loc) • 2.29 kB
TypeScript
import type { 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 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 applySerializedActionAndSyncNewModelIds<TRet = any>(subtreeRoot: object, call: SerializedActionCallWithModelIdOverrides): TRet;