Skip to content

Instantly share code, notes, and snippets.

@jporcenaluk
Created April 27, 2021 09:20
Show Gist options
  • Select an option

  • Save jporcenaluk/14c2fd872a9400c5ebc9d03f480f3509 to your computer and use it in GitHub Desktop.

Select an option

Save jporcenaluk/14c2fd872a9400c5ebc9d03f480f3509 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: 'resetMachine',
initial: 'resetInit',
states: {
resetInit: {
invoke: {
id: 'resetInit',
src: 'checkReset',
onDone: 'success',
onError: 'needsReset'
},
},
needsReset: {
on: {
SUBMIT: 'pending'
}
},
pending: {
initial: 'reset',
states: {
reset: {
invoke: {
id: 'reset',
src: 'requestReset',
onError: '#resetMachine.error',
onDone: 'wait'
},
},
wait: {
after: {
5000: 'checkReset'
}
},
checkReset: {
invoke: {
id: 'reset',
src: 'requestReset',
onError: '#resetMachine.error',
onDone: '#resetMachine.success'
},
}
}
},
success: {
type: 'final'
},
error: {
on: {
SUBMIT: 'pending'
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment