smartstate/ts/smartstate.classes.stateaction.ts

21 lines
622 B
TypeScript
Raw Permalink Normal View History

2022-03-25 12:31:21 +00:00
import * as plugins from './smartstate.plugins.js';
import { StatePart } from './smartstate.classes.statepart.js';
2020-11-29 23:51:05 +00:00
export interface IActionDef<TStateType, TActionPayloadType> {
(stateArg: StatePart<any, TStateType>, actionPayload: TActionPayloadType): Promise<TStateType>;
}
/**
* an actionmodifier for the state
*/
export class StateAction<TStateType, TActionPayloadType> {
constructor(
public statePartRef: StatePart<any, any>,
public actionDef: IActionDef<TStateType, TActionPayloadType>
) {}
public trigger(payload: TActionPayloadType) {
this.statePartRef.dispatchAction(this, payload);
}
}