Skip to content

Instantly share code, notes, and snippets.

@wmcbain
Created March 5, 2020 00:59
Show Gist options
  • Save wmcbain/d5fa453da850d7be20498abb9222b3cb to your computer and use it in GitHub Desktop.
Save wmcbain/d5fa453da850d7be20498abb9222b3cb 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 authMachine = Machine({
id: 'auth_machine',
initial: 'authIsLoading',
context: {
alleToken: null,
registrationFields: {
firstName: '',
lastName: '',
emailAddress: '',
password: '',
},
},
states: {
authIsLoading: {
on: {
LOGGED_IN: 'isLoggedIn',
NOT_LOGGED_IN: 'isNotLoggedIn',
},
},
// HOME SCREEN
isLoggedIn: {
entry: 'redirectToAccount',
type: 'final',
},
// HOME SCREEN
isNotLoggedIn: {
on: {
REGISTER: 'forkInRoad',
DEEPLINK_PHONE_NUMBER: 'registerUser',
},
},
forkInRoad: {
entry: 'redirectToForkInRoad',
on: {
REGISTER_PHONE_NUMBER: 'registerPhoneNumber',
},
},
// REGISTER PHONE SCREEN
registerPhoneNumber: {
entry: 'redirectToRegisterPhoneNumber',
on: {
PHONE_NUMBER_SUBMITTED: 'submitPhoneNumber',
},
},
submitPhoneNumber: {
entry: 'phoneNumberSubmitted',
type: 'final',
},
// REGISTER USER SCREEN
registerUser: {
entry: 'verifyPhoneNumber',
on: {
USER_REGISTERED: 'isLoggedIn',
},
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment