Skip to content

Instantly share code, notes, and snippets.

@kappuccino
Created May 14, 2020 06:20
Show Gist options
  • Save kappuccino/94577229ffb30ca83a96adc719bbdaef to your computer and use it in GitHub Desktop.
Save kappuccino/94577229ffb30ca83a96adc719bbdaef to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine({
id: 'lightBulb',
initial: 'lit',
states: {
lit: {
exit: () => {
console.log('it is cold')
},
on: {
BREAK: {
target: 'broken',
actions: () => {
console.log('transition to broken')
}
},
TOGGLE: 'unlit'
}
},
unlit: {
on: {
BREAK: 'broken',
TOGGLE: 'lit'
}
},
broken:{
entry: ['logBroken']
}
}
}, {
actions: {
logBroken: (ctx, event) => {
console.log(`yo i am broke in ${event.location}`)
}
}})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment