Skip to content

Instantly share code, notes, and snippets.

@jalalazimi
Last active September 7, 2020 21:48
Show Gist options
  • Save jalalazimi/b542c5eac1eb3286254ca40b5552c8d9 to your computer and use it in GitHub Desktop.
Save jalalazimi/b542c5eac1eb3286254ca40b5552c8d9 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const fetchMachine = Machine({
id: "lightBulb",
initial: "unlit",
states: {
lit: {
exit:()=>{
console.log("It's so dark and cold")
},
on: {
BREAK: {target: 'broken',actions: ()=>{
console.log('transition to broken')
}},
TOGGLE: "unlit",
},
},
unlit: {
on: {
BREAK: 'broken',
TOGGLE: "lit",
},
},
broken: { entry: ['logBroken'] },
},
},{
actions: {
logBroken: (context,event)=>{console.log(`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