Skip to content

Instantly share code, notes, and snippets.

@zaydek
Created September 19, 2020 20:03
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 zaydek/eda79378a2e339e4f6211d464593862b to your computer and use it in GitHub Desktop.
Save zaydek/eda79378a2e339e4f6211d464593862b to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const refetchForeverMachine = Machine({
id: "refetchForever",
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: "failure",
},
},
failure: {
on: {
"": "fetching",
},
},
success: {
type: "final",
},
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment