@edgeflowjs/flow
v0.2.2
Published
State machine engine for deterministic kiosk flows.
Readme
@edgeflowjs/flow
State machine engine for deterministic kiosk flows.
Install
pnpm add @edgeflowjs/flowIn a workspace: "@edgeflowjs/flow": "workspace:*"
Exports
defineFlow— Create a flow definitioncreateFlowEngine— Create the runtimecreateMemoryFlowStore— In-memory persistence (MVP)- Types:
FlowDef,FlowEvent,FlowEngine,FlowStore,FlowInstanceSnapshot,FlowStateDef,TransitionGuard,TransitionAction
Usage
import { defineFlow, createFlowEngine, createMemoryFlowStore } from "@edgeflowjs/flow";
const flow = createFlowEngine(createMemoryFlowStore());
flow.register(defineFlow({
id: "purchase",
initial: "idle",
states: { idle: { on: { START: "scan" } }, scan: { on: { DONE: "idle" } } },
}));
await flow.start("purchase", { instanceId: "main", ctx: {} });
await flow.dispatch("main", { type: "START" });