Skip to content

Instantly share code, notes, and snippets.

@njdancer
Last active October 10, 2019 22:57
Show Gist options
  • Save njdancer/7763405d44955751d4dedf05b7a0d87f to your computer and use it in GitHub Desktop.
Save njdancer/7763405d44955751d4dedf05b7a0d87f 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({
id: 'fetch',
initial: 'idle',
context: {
retries: 0
},
states: {
idle: {
on: {
"": 'loading'
}
},
loading: {
initial: "loading",
states: {
loading: {
on: {
"SUCCESS": "loaded",
"FAILURE": "failed",
}
},
loaded: {
type: "final"
},
failed: {}
},
onDone: "success",
onError: "failed"
},
success: {
type: 'final'
},
failed: {
type: "final"
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment