Skip to content

Instantly share code, notes, and snippets.

@NilsonLima
Last active April 5, 2020 13:54
Show Gist options
  • Save NilsonLima/613e9dece8b318d2f3f79a9d606b3dcd to your computer and use it in GitHub Desktop.
Save NilsonLima/613e9dece8b318d2f3f79a9d606b3dcd 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 fetchMachine = Machine({
id: 'cancel',
initial: 'idle',
context: {
retries: 0
},
states: {
idle: {
on: {
REQUEST_CONFIRMATION: 'confirmation'
}
},
confirmation: {
on: {
NO: 'idle',
YES: 'fetching'
}
},
fetching: {
on: {
SUCCESS: 'survey',
FAIL: 'error'
}
},
survey: {
type: 'final'
},
error: {
onEntry: ['raiseToast']
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment