Created
December 11, 2019 19:03
-
-
Save Jpadilla1/656ce479188d4b1ab9330045949b3066 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains 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 statusMachine = Machine({ | |
id: 'status-machine', | |
type: 'parallel', | |
states: { | |
polling: { | |
initial: 'loading', | |
states: { | |
loading: { | |
invoke: { | |
src: 'sparkRequest', | |
onDone: 'success', | |
onError: 'failure', | |
}, | |
}, | |
success: { | |
entry: 'transitionToEnabled', | |
after: { | |
4000: 'loading', | |
}, | |
}, | |
failure: { | |
entry: 'transitionToDisabled', | |
after: { | |
4000: 'loading', | |
}, | |
}, | |
}, | |
}, | |
status: { | |
initial: 'disabled', | |
states: { | |
disabled: { | |
on: { | |
enable: 'enabled', | |
}, | |
}, | |
enabled: { | |
on: { | |
disable: 'disabled', | |
}, | |
}, | |
}, | |
}, | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment