1 line
1.3 KiB
Plaintext
1 line
1.3 KiB
Plaintext
|
{"version":3,"file":"StateManager.js","sourceRoot":"","sources":["../../src/utils/StateManager.ts"],"names":[],"mappings":";;AAAA,MAAqB,YAAY;IAK/B,YAAmB,KAAgB;QAAhB,UAAK,GAAL,KAAK,CAAW;QACnC,aAAa;QACb,mBAAc,GAAmD,EAAE,CAAC;QACpE,aAAa;QACb,gBAAW,GAKyE,MAAM,CAAC,EAAE;YAC3F,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,aAAa,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;YACnF,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;YACnB,aAAa;YACb,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,GAAG,aAAa,CAAC;YAChD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;IAfoC,CAAC;CAgBxC;AArBD,+BAqBC","sourcesContent":["export default class StateManager<\n StateType,\n AppliedActionResultType,\n ActionName extends string = never\n> {\n constructor(public state: StateType) {}\n // @ts-ignore\n appliedActions: { [K in ActionName]: AppliedActionResultType } = {};\n // @ts-ignore\n applyAction: <NewActionName extends string>(\n action: (\n content: StateType,\n actions: { [K in ActionName]: AppliedActionResultType }\n ) => [StateType, NewActionName, AppliedActionResultType]\n ) => StateManager<StateType, AppliedActionResultType, ActionName | NewActionName> = action => {\n const [state, actionName, appliedAction] = action(this.state, this.appliedActions);\n this.state = state;\n // @ts-ignore\n this.appliedActions[actionName] = appliedAction;\n return this;\n };\n}\n"]}
|