Skip to content

Instantly share code, notes, and snippets.

@iamstarkov
Last active February 13, 2020 15:56
Show Gist options
  • Save iamstarkov/8ab1f1a64f3cda3fcae562b940f53643 to your computer and use it in GitHub Desktop.
Save iamstarkov/8ab1f1a64f3cda3fcae562b940f53643 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
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