Files
smartstate/ts/smartstate.classes.stateaction.ts

18 lines
621 B
TypeScript
Raw Normal View History

2019-02-21 21:48:39 +01:00
import * as plugins from './smartstate.plugins';
2019-02-26 18:09:38 +01:00
import { StatePart } from './smartstate.classes.statepart';
export interface IActionDef<TStateType, TActionPayloadType> {
2019-02-27 02:00:47 +01:00
(stateArg: StatePart<any, TStateType>, actionPayload: TActionPayloadType): Promise<TStateType>;
2019-02-26 18:09:38 +01:00
}
2019-02-21 21:48:39 +01:00
/**
* an actionmodifier for the state
*/
2019-02-26 18:09:38 +01:00
export class StateAction<TStateType, TActionPayloadType> {
2019-09-25 15:28:39 +02:00
constructor(public statePartRef: StatePart<any, any>, public actionDef: IActionDef<TStateType, TActionPayloadType>) {}
public trigger(payload: TActionPayloadType) {
this.statePartRef.dispatchAction(this, payload);
}
2019-02-21 21:48:39 +01:00
}