Created
December 19, 2019 15:57
-
-
Save RainerAtSpirit/c0a469e818d6ed8e5d430f15b901b298 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or 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 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