Last active
November 25, 2019 00:28
-
-
Save dimsuz/f96833dea1b8774be65aee29bfefaf67 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains 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 loginStates = { | |
id: 'login_screen', | |
initial: 'login', | |
states: { | |
login: { | |
} | |
} | |
} | |
const otpStates = { | |
id: 'otp_screen', | |
initial: 'otp_intro', | |
states: { | |
otp_intro: { | |
on: { | |
'OTP_INTRO_CONTINUE': 'otp_input' | |
} | |
}, | |
otp_input: { | |
} | |
} | |
} | |
const pinCreateStates = { | |
id: 'pin_create_screens', | |
initial: 'pin_intro', | |
states: { | |
pin_intro: { | |
on: { | |
'PIN_INTRO_CONTINUE': 'pin_create', | |
'BACK': 'dismissed' | |
} | |
}, | |
pin_create: { | |
on: { | |
'BACK': 'pin_intro', | |
'PIN_CREATE_SUCCESS': 'success' | |
} | |
}, | |
dismissed: { | |
type: 'final' | |
}, | |
success: { | |
type: 'final' | |
} | |
} | |
} | |
const fetchMachine = Machine({ | |
id: 'fetch', | |
initial: 'flow_login', | |
context: { | |
retries: 0 | |
}, | |
states: { | |
flow_login: { | |
on: { | |
'LOGIN_SUCCESS_OTP_REQUIRED': 'flow_otp', | |
'LOGIN_SUCCESS_OTP_NOT_REQUIRED': 'flow_pin_create' | |
}, | |
...loginStates | |
}, | |
flow_otp: { | |
on: { | |
'BACK': 'flow_login' | |
}, | |
...otpStates | |
}, | |
flow_pin_create: { | |
...pinCreateStates, | |
on: { | |
}, | |
// TODO or to flow_login depending on who opened! | |
onDone: 'flow_otp' | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment