smartstate/ts/smartstate.classes.stateaction.ts

18 lines
621 B
TypeScript
Raw Permalink Normal View History

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