Skip to content

Instantly share code, notes, and snippets.

@tomByrer
Last active October 19, 2020 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomByrer/d87ef45197e075dca7cba55ad594d160 to your computer and use it in GitHub Desktop.
Save tomByrer/d87ef45197e075dca7cba55ad594d160 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// source: https://egghead.io/lessons/xstate-simplify-state-explosion-in-xstate-through-hierarchical-states
const door = Machine({
id: 'door',
initial: 'locked',
states: {
locked: {
id: 'locked',
on: {
UNLOCK: 'unlocked'
}
},
unlocked: {
initial: 'closed',
states: {
closed: {
on: {
OPEN: 'opened'
}
},
opened: {
on: {
LOCK: '#locked',
CLOSE: 'closed'
}
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment