Back to packages list

Vals using xstate

Description from the NPM package:
Finite State Machines and Statecharts for the Modern Web.
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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
let { xstateStateEx } = await import("https://esm.town/v/stevekrouse/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;
};
1
Next