Skip to content

Instantly share code, notes, and snippets.

@hamatoyogi
Created November 22, 2020 14:00
Show Gist options
  • Save hamatoyogi/779c4576ba302fd0fe955317a68e06d2 to your computer and use it in GitHub Desktop.
Save hamatoyogi/779c4576ba302fd0fe955317a68e06d2 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: 'Opportunity',
initial: 'uninitiated',
context: {
retries: 0
},
states: {
uninitiated: {
on: {
ACTIVE: 'loading'
}
},
loading: {
on: {
RESOLVE: 'cmopleted',
REJECT: 'canceled'
}
},
cmopleted: {
type: 'final'
},
canceled: {
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