Skip to content

Instantly share code, notes, and snippets.

@XHMM
Created April 11, 2021 17:25
Show Gist options
  • Save XHMM/a9d300650d45c63c16c74116f6dabe40 to your computer and use it in GitHub Desktop.
Save XHMM/a9d300650d45c63c16c74116f6dabe40 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const fetchMachine = Machine({
initial: "idle",
states: {
idle: {
on: {
FETCH: {
target: "fetching",
},
},
},
fetching: {
invoke: {
src: "customFetch",
onDone: "success",
onError: "fail",
},
},
fail: {
on: {
RETRY: {
target: "fetching",
},
},
},
success: {},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment