Created
September 19, 2020 20:03
-
-
Save zaydek/eda79378a2e339e4f6211d464593862b to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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