Public
Script
Forked from stevekrouse/xstateEx
October 23, 2023
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
let { xstateStateEx } = await import("https://esm.town/v/frankysnow/xstateStateEx");
export const xstateEx = async (event: string) => {
const { createMachine } = await import("npm:xstate");
const toggleMachine = createMachine({
id: "toggle",
initial: "inactive",
states: {
inactive: { on: { TOGGLE: "active" } },
active: { on: { TOGGLE: "inactive" } },
},
});
let state = xstateStateEx || toggleMachine.initialState;
return xstateStateEx =
toggleMachine.transition(state, event).value;
};
// Forked from @stevekrouse.xstateEx
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
October 23, 2023