Last active
June 15, 2021 14:42
-
-
Save cunneen/7e11fd5842328eac8664527d731d6d22 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const fetchMachine = Machine({ | |
id: 'Totally Auth', | |
initial: 'unauthorised', | |
context: { | |
retries: 0 | |
}, | |
states: { | |
unauthorised: { | |
on: { | |
REGISTER: 'registration form', | |
LOGIN: 'login form' | |
} | |
}, | |
'login form': { | |
on: { | |
SUBMIT: 'awaiting login response', | |
CANCEL: 'unauthorised' | |
} | |
}, | |
'awaiting login response': { | |
on: { | |
SUCCESS: 'confirmation code form', | |
ERROR: 'login form' | |
} | |
}, | |
'registration form': { | |
on: { | |
SUBMIT: 'awaiting reg response', | |
ERROR: 'registration form', | |
CANCEL: 'unauthorised' | |
} | |
}, | |
'awaiting reg response': { | |
on: { | |
SUCCESS: 'awaiting conformation code', | |
ERROR: 'registration form' | |
} | |
}, | |
'awaiting conformation code': { | |
on: { | |
OK: 'confirmation code form' | |
} | |
}, | |
'confirmation code form': { | |
on: { | |
SUBMIT: 'confirmation code check', | |
CANCEL: 'unauthorised', | |
RESEND: 'awaiting conformation code' | |
} | |
}, | |
'confirmation code check': { | |
on: { | |
OK: 'authenticated', | |
ERROR: 'confirmation code form' | |
} | |
}, | |
authenticated: { | |
type: 'final' | |
}, | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment