Skip to content

Instantly share code, notes, and snippets.

@ondrasak
Created October 19, 2021 12:08
Show Gist options
  • Select an option

  • Save ondrasak/9f276064d813b53c2bcf25d6ef531293 to your computer and use it in GitHub Desktop.

Select an option

Save ondrasak/9f276064d813b53c2bcf25d6ef531293 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const AuthenticateMachine = Machine({
id: 'Authenticate',
initial: 'start',
context: {
retries: 0
},
states: {
start: {
on: {
CHECK_OAUTH: 'OAuthCheck'
}
},
OAuthCheck: {
meta: {
description: 'this chcek by the URL if oAuth is in proggress'
},
onEntry: ['OAuthCheckHandler'],
on: {
NEXT: [
{
target: 'OAuthProcess',
cond:'isOauthInProggress'
},
{
target: 'EventUserAuthentication'
}
]
}
},
OAuthProcess: {
onEntry: ['OAuthCheckHandler']
},
EventUserAuthentication: {}
}
}, {
actions: {
OAuthCheckHandler: () => {
send('NEXT')
}
},
guards: {
isOauthInProggress: () => false
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment