Skip to content

Instantly share code, notes, and snippets.

@jhesgodi
Last active February 25, 2021 05:04
Show Gist options
  • Save jhesgodi/0408cfd688a6dd919ccf2044d87ab9c2 to your computer and use it in GitHub Desktop.
Save jhesgodi/0408cfd688a6dd919ccf2044d87ab9c2 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)
// V1
// const fetchMachine = Machine({
// id: 'door',
// initial: 'locked',
// states: {
// locked: {
// on: {
// UNLOCK: 'unlocked'
// }
// },
// unlocked: {
// on: {
// LOCK: 'locked',
// OPEN: 'opened'
// }
// },
// opened: {
// on: {
// CLOSE: 'closed'
// }
// },
// closed: {
// on: {
// LOCK: 'locked',
// OPEN: 'opened'
// }
// },
// }
// })
// V2
const fetchMachine = Machine({
id: 'door',
initial: 'locked',
states: {
locked: {
id: 'locked',
on: {
UNLOCK: 'unlocked'
}
},
unlocked: {
initial: 'closed',
states: {
closed: {
on: {
LOCK: '#locked',
OPEN: 'opened'
}
},
opened: {
on: {
CLOSE: 'closed'
}
},
}
},
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment