Last active
February 13, 2020 15:56
-
-
Save iamstarkov/8ab1f1a64f3cda3fcae562b940f53643 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 fetchMachine = Machine({ | |
id: 'root', | |
initial: 'INIT', | |
states: { | |
'INIT': { | |
on: { | |
'*': [ | |
{ | |
target: 'MAYBE AUTHORIZED', | |
cond: 'hasAuthorizationCode' | |
}, | |
{ target: 'NOT AUTHORIZED' } | |
] | |
} | |
}, | |
'NOT AUTHORIZED': { | |
on: { | |
'LOGIN': 'AUTHORIZING' | |
} | |
}, | |
'AUTHORIZING': { | |
entry: 'redirectToProvider' | |
}, | |
'MAYBE AUTHORIZED': { | |
on: { | |
'*':[ | |
{ | |
target: 'REQUESTING ACCESS TOKEN', | |
cond: 'hasAuthorizationCode' | |
}, | |
{ target: 'NOT AUTHORIZED' } | |
] | |
}, | |
}, | |
'REQUESTING ACCESS TOKEN': { | |
entry: 'exchangeAuthCodeForAccessToken', | |
on: { | |
'SUCC': 'REQUESTING SESSION', | |
'FAIL': 'FAILURE' | |
} | |
}, | |
'REQUESTING SESSION': { | |
on: { | |
'SUCC': 'AUTHORIZED', | |
'FAIL': 'FAILURE' | |
} | |
}, | |
'AUTHORIZED': { | |
// on: | |
}, | |
'FAILURE': {} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment