smartstate/ts/smartstate.classes.stateaction.ts
2019-09-25 15:28:39 +02:00

18 lines
621 B
TypeScript

import * as plugins from './smartstate.plugins';
import { StatePart } from './smartstate.classes.statepart';
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);
}
}