begin building Tick
This commit is contained in:
+20
-1
@@ -26,6 +26,11 @@ export const On = function<S,E extends EventShape>(eventName:E[0], ...reactions:
|
||||
export const Do = function(fn:DoFn_T) : Do_T{ return {type:'Do', fn}; };
|
||||
export const Goto = function<S>(targetStateName:S) : Goto_T<S> { return {type:'Goto', targetStateName} };
|
||||
|
||||
interface Tick_T {
|
||||
doFunctions: Array<DoFn_T>
|
||||
};
|
||||
const Tick = function(doFunctions : Array<DoFn_T>) : Tick_T{ return {doFunctions}; };
|
||||
|
||||
|
||||
export interface Interpreter_T<S,E extends EventShape,C> {
|
||||
machine: Machine_T<S,E>;
|
||||
@@ -62,7 +67,21 @@ function getOns<S,E extends EventShape>(state : State_T<S,E>, event:E) : Array<O
|
||||
export function send<S,E extends EventShape,C>(interpreter : Interpreter_T<S,E,C>, event:E){
|
||||
const state = getState(interpreter);
|
||||
const ons = getOns(state, event);
|
||||
ons.forEach
|
||||
const tick = Tick(ons
|
||||
.map((on)=>on.reactions)
|
||||
.flat()
|
||||
.map((reaction)=>{
|
||||
if(reaction.type === 'Do'){
|
||||
return reaction.fn;
|
||||
}
|
||||
else if(reaction.type === 'Goto'){
|
||||
return (ctx,e,self)=>{};
|
||||
}
|
||||
else{
|
||||
return (ctx,e,self)=>{};
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
export const Spawn = function(){};
|
||||
|
||||
Reference in New Issue
Block a user