Skip to content

Instantly share code, notes, and snippets.

@zaydek
Last active September 19, 2020 19:41
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/9585a39bba67b5c9cf2fc980e45ab270 to your computer and use it in GitHub Desktop.
Save zaydek/9585a39bba67b5c9cf2fc980e45ab270 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine({
id: "fetch",
initial: "fetching",
states: {
// idle: {
// on: {
// FETCH: "fetching",
// },
// },
fetching: {
invoke: {
id: "fetchHandler",
src: () => {
setTimeout(() => {
// ...
}, 1000)
},
onDone: "success",
onError: "failure",
},
},
success: {
type: "final",
},
failure: {
on: {
REFETCH: "fetching"
},
},
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment