Last active
November 29, 2020 18:05
-
-
Save alveshelio/fdf164d2d12ad6e13dddf8aa58b32776 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const lit = { | |
on: { | |
BREAK: { | |
target: 'broken', | |
actions: () => console.warn('transition to onBreak') | |
}, | |
TOGGLE: 'unlit', | |
}, | |
exit: () => console.warn("it's dark and cold") | |
} | |
const unlit = { | |
on: { | |
BREAK: 'broken', | |
TOGGLE: 'lit' | |
}, | |
} | |
const broken = { | |
entry: ['logBroken'] | |
} | |
const states = { lit, unlit, broken } | |
const initial = 'unlit' | |
const config = { | |
id: 'lightBulb', | |
initial, | |
states, | |
strict: true, | |
devTools: true, | |
} | |
const lightBulbMachine = Machine(config, { | |
actions: { | |
logBroken: (context, event) => console.warn(`yo I'm broken in the ${event.location}`) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment