Skip to content

Instantly share code, notes, and snippets.

@itacirgabral
Created September 29, 2021 04:43
Show Gist options
  • Save itacirgabral/2ea77cf325a5acec3ffe02c6bb11e1e7 to your computer and use it in GitHub Desktop.
Save itacirgabral/2ea77cf325a5acec3ffe02c6bb11e1e7 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const machine = Machine({
id: 'lightbulb',
initial: 'unlit',
states: {
lit: {
on: {
TOGGLE: 'unlit',
BREAK: 'broken'
}
},
unlit: {
exit: () => {},
on: {
TOGGLE: 'lit',
BREAK: {
target: 'broken',
actions: [(ctx, e) => {
console.log(e.myArg)
}, 'logB']
}
}
},
broken: {
type: 'final',
entry: (ctx, e) => {} // ['a', 'b']
}
},
strict: true
}, {
actions: {
logB: () => console.log('b')
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment