Skip to content

Instantly share code, notes, and snippets.

@zaydek

zaydek/machine.js

Created Sep 19, 2020
Embed
What would you like to do?
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
You can’t perform that action at this time.