Skip to content

Instantly share code, notes, and snippets.

@pyoner
Created December 9, 2019 15:24
Show Gist options
  • Save pyoner/e9a7a4e45a2fcc52d6fc9a5aa1e645c7 to your computer and use it in GitHub Desktop.
Save pyoner/e9a7a4e45a2fcc52d6fc9a5aa1e645c7 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: 'idle',
context: {
retries: 0
},
states: {
idle: {
on: {
FETCH: 'async fetch'
}
},
'async fetch': {
initial: 'await',
states: {
await: {
invoke: {
src: 'fetchData',
onDone: '#fetch.success',
onError: 'err'
}
},
err: {
on: {
RETRY: 'await'
}
}
}
},
success: {
type: 'final'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment