Skip to content

Instantly share code, notes, and snippets.

@zaydek
Created September 19, 2020 19:58
Show Gist options
  • Save zaydek/38803af4128169b2a0c043fd048d741f to your computer and use it in GitHub Desktop.
Save zaydek/38803af4128169b2a0c043fd048d741f to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const naiveRefetchForeverMachine = Machine({
id: "naiveRefetchForever",
initial: "fetching",
states: {
fetching: {
invoke: {
id: "fetchHandler",
src: (ctx, e) => new Promise((resolve, reject) => {
setTimeout(() => {
// if (Math.random() < 0.5) {
reject()
// } else {
// resolve()
// }
}, 1e3)
}),
onDone: "success",
onError: "fetching",
},
},
success: {
type: "final",
},
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment