mobx-keystone
Version:
A MobX powered state management solution based on data trees with first class support for TypeScript, snapshots, patches and much more
37 lines (36 loc) • 1.12 kB
TypeScript
import { Path } from '../parent/pathTypes';
/**
* An action call.
*/
export interface ActionCall {
/**
* Action name (name of the function).
*/
readonly actionName: string;
/**
* Action arguments.
*/
readonly args: ReadonlyArray<any>;
/**
* Path to the model where the action will be run, as an array of string | number.
*/
readonly targetPath: Path;
/**
* Ids of models along the path to the target, null if it is not a model.
*/
readonly targetPathIds: ReadonlyArray<string | null>;
/**
* Marks this action call as non-serialized.
*/
readonly serialized?: boolean;
}
/**
* Applies (runs) an action over a target object.
*
* If you intend to apply serialized actions check one of the `applySerializedAction` methods instead.
*
* @param subtreeRoot Subtree root target object to run the action over.
* @param call The action, usually as coming from `onActionMiddleware`.
* @returns The return value of the action, if any.
*/
export declare function applyAction<TRet = any>(subtreeRoot: object, call: ActionCall): TRet;