Skip to content

Instantly share code, notes, and snippets.

@RainerAtSpirit
Created December 19, 2019 15:57
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 RainerAtSpirit/c0a469e818d6ed8e5d430f15b901b298 to your computer and use it in GitHub Desktop.
Save RainerAtSpirit/c0a469e818d6ed8e5d430f15b901b298 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine(
{
id: "fetch",
initial: "idle",
context: {
retries: 0
},
states: {
idle: {
initial: 'noError',
states: {
error: {},
noError: {}
},
on: {
CHANGE: [
{
target: 'idle.error',
cond: 'hasErrors'
},
{
target: 'idle.noError'
}
]
},
exit: ['resetError', 'setValue']
}
}
},
{
actions: {
resetError: () => console.log("resetError"),
setValue: () => console.log("setValue")
},
guards: {
hasErrors: () => true
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment