Skip to content

Instantly share code, notes, and snippets.

@Valkendorm
Created April 9, 2021 23:34
Show Gist options
  • Save Valkendorm/bd8acacfb5d018a3ef7ec1e3fd56bdf3 to your computer and use it in GitHub Desktop.
Save Valkendorm/bd8acacfb5d018a3ef7ec1e3fd56bdf3 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 doorMachine = Machine({
states: {
door: {
id: "door",
initial: 'closed',
states: {
closed: {},
opened: {
on: {
CLOSE_DOOR: 'closed'
}
}
}
},
handle: {
id: "handle",
initial: 'released',
states: {
released: {
initial: 'unlocked',
states: {
unlocked: {
on: {
TOGGLE_LOCK: 'locked',
TURN_HANDLE: '#handle.turned'
}
},
locked: {
on: {
TOGGLE_LOCK: 'unlocked'
}}
}
},
turned: {
on: {
OPEN_DOOR: '#door.opened',
RELEASE_HANDLE: 'released'
}
}
}
}
},
type: 'parallel'
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment