Skip to content

Instantly share code, notes, and snippets.

@rads
Last active November 27, 2019 03:28
Show Gist options
  • Save rads/1c282c97e87aca343a6dc0b8dc037359 to your computer and use it in GitHub Desktop.
Save rads/1c282c97e87aca343a6dc0b8dc037359 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: 'supervisor',
initial: 'unmounted',
context: {
retries: 0
},
states: {
unmounted: {
on: {
START: 'loading'
}
},
loading: {
on: {
RESOLVE: 'success',
REJECT: 'failure'
}
},
success: {
type: 'final'
},
failure: {
on: {
RETRY: {
target: 'loading',
actions: assign({
retries: (context, event) => context.retries + 1
})
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment