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
22 lines (21 loc) • 798 B
TypeScript
import type { ActionMiddlewareDisposer } from "../action/middleware";
import type { AnyModel } from "../model/BaseModel";
/**
* Creates a transaction middleware, which reverts changes made by an action / child
* actions when the root action throws an exception by applying inverse patches.
*
* @typeparam M Model
* @param target Object with the root target model object (`model`) and root action name (`actionName`).
* @returns The middleware disposer.
*/
export declare function transactionMiddleware<M extends AnyModel>(target: {
model: M;
actionName: keyof M;
}): ActionMiddlewareDisposer;
/**
* Transaction middleware as a decorator.
*
* @param target
* @param propertyKey
*/
export declare function transaction(target: any, propertyKey: string): void;