Created
March 5, 2020 00:59
-
-
Save wmcbain/d5fa453da850d7be20498abb9222b3cb 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 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