Created
September 13, 2019 16:06
-
-
Save jeremy-green/7ffa9ad01246650c5887c39406d85ef1 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
new Machine({ | |
id: 'wink-initializer', | |
initial: 'idle', | |
context: {}, | |
states: { | |
idle: { | |
on: { | |
'': 'bootstrap', | |
}, | |
}, | |
bootstrap: { | |
initial: 'getToken', | |
states: { | |
getToken: { | |
invoke: { | |
src: () => new Promise(r => setTimeout(() => r({ accessToken: '' }), 2500)), | |
onDone: { | |
target: 'getDevices', | |
actions: [(context, { data: { accessToken } }) => console.log(accessToken)], | |
}, | |
onError: { target: '#wink-initializer.idle' }, | |
}, | |
}, | |
getDevices: { | |
invoke: { | |
src: () => new Promise(r => setTimeout(() => r({ data: {} }), 2500)), | |
onDone: { target: '#wink-initializer.ready' }, | |
onError: { target: '#wink-initializer.idle' }, | |
}, | |
}, | |
}, | |
}, | |
ready: { | |
entry: [(context, { data: { data } }) => console.log('data', [...data])], | |
type: 'final', | |
}, | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment