Skip to content

Instantly share code, notes, and snippets.

@alexreardon
Last active May 31, 2021 03:57
Show Gist options
  • Select an option

  • Save alexreardon/e8a08f5510816fb2ca389543424e7eda to your computer and use it in GitHub Desktop.

Select an option

Save alexreardon/e8a08f5510816fb2ca389543424e7eda to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const machine = Machine({
id: 'save-button',
initial: 'hiding',
states: {
hiding: {
on: {
SHOW: 'waiting',
},
},
waiting: {
// while waiting we can jump straight to the confirmation
on: {
SAVED: 'showing-confirmation',
},
after: {
// using this approach for the timer as it works nicer with the xstate visualizer devtool
2000: 'showing-invitation',
},
},
'showing-invitation': {
on: {
SAVED: 'showing-confirmation',
},
},
'showing-confirmation': {},
},
on: {
HIDE: 'hiding',
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment