import {Context} from "./context"; import {Command} from "../utils/command"; import {effect} from "@preact/signals-core"; export type RuleContext = Context & { actions: Command[]; handledActions: number; invocations: RuleContext[]; resolution?: T; } function invokeRuleContext(pushContext: (context: Context) => void, type: string, rule: Generator){ const ctx: RuleContext = { type, actions: [], handledActions: 0, invocations: [], resolution: undefined, } const dispose = effect(() => { if(ctx.resolution) { dispose(); return; } }); pushContext(rule); } function* rule(){ const play: Command = yield 'play'; }