Skip to content

Instantly share code, notes, and snippets.

@snikch
Created March 9, 2021 19:45
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 snikch/32705b2e2ffdb0ea7e6dfb8cca44a820 to your computer and use it in GitHub Desktop.
Save snikch/32705b2e2ffdb0ea7e6dfb8cca44a820 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: 'fetch',
initial: 'request',
context: {
retries: 0
},
states: {
request: {
on: {
"error": 'failure',
"other": 'failure',
"401": 'refreshToken',
"50x": 'failure',
"200": 'success'
}
},
refreshToken: {
on: {
"error": 'failure',
"other": 'failure',
"400": 'revoked',
"50x": 'failure',
"200": 'request',
}
},
success: {
type: 'final'
},
failure: {
type: 'final'
},
revoked: {
type: 'final'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment