Created
September 17, 2019 21:57
-
-
Save jeremy-green/34d3f306a5b8f62ea3557bc1073be0a2 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: 'initializer', | |
initial: 'idle', | |
context: {}, | |
states: { | |
idle: { | |
on: { | |
'': 'getToken', | |
}, | |
}, | |
getToken: { | |
invoke: { | |
src: () => new Promise(resolve => setTimeout(() => resolve({ access_token: '' }), 2500)), | |
onDone: { | |
target: 'getDevices', | |
actions: [ | |
(context, { data: { access_token: accessToken } }) => console.log(accessToken), | |
], | |
}, | |
onError: { target: 'getToken' }, | |
}, | |
}, | |
getDevices: { | |
invoke: { | |
src: (context, { data: { access_token: accessToken } }) => new Promise(resolve => setTimeout(() => resolve({}, 2500))), | |
onDone: { target: 'ready' }, | |
onError: { target: 'getDevices' }, | |
}, | |
}, | |
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