refactor: mass refactoring
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import {Context} from "./context";
|
||||
import {Command} from "../utils/command";
|
||||
import {effect} from "@preact/signals-core";
|
||||
|
||||
export type RuleContext<T> = Context & {
|
||||
actions: Command[];
|
||||
handledActions: number;
|
||||
invocations: RuleContext<unknown>[];
|
||||
resolution?: T;
|
||||
}
|
||||
|
||||
function invokeRuleContext<T>(pushContext: (context: Context) => void, type: string, rule: Generator<string, T, Command>){
|
||||
const ctx: RuleContext<T> = {
|
||||
type,
|
||||
actions: [],
|
||||
handledActions: 0,
|
||||
invocations: [],
|
||||
resolution: undefined,
|
||||
}
|
||||
const dispose = effect(() => {
|
||||
if(ctx.resolution) {
|
||||
dispose();
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
pushContext(rule);
|
||||
}
|
||||
|
||||
function* rule(){
|
||||
const play: Command = yield 'play';
|
||||
}
|
||||
Reference in New Issue
Block a user