Last active
October 27, 2019 19:58
-
-
Save AndreiCalazans/757a7102d7c52a1595d47647c132644d 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 keepHistory = assign({ | |
| // screenHistory: (context, event) => [...context.screenHistory] | |
| // }); | |
| const withScreenState = (rest) => ({ | |
| entry: "updateScreenHistory", | |
| ...rest | |
| }) | |
| const LogInState = (backTo, eventOptions = {}) => ({ | |
| initial: 'idle', | |
| on: { | |
| back: backTo | |
| }, | |
| states: { | |
| idle: { | |
| on: { | |
| submit: 'validating', | |
| ...eventOptions, | |
| } | |
| }, | |
| validating: { | |
| on: { | |
| success: '#App.SelectSubscription' | |
| } | |
| }, | |
| ForgotPassword: {}, | |
| } | |
| }); | |
| const SignInState = LogInState('SignIn', { | |
| signup: '#App.SignUp', | |
| forgotPassword: 'ForgotPassword' | |
| }); | |
| const SignUpState = LogInState('SignIn', { | |
| signin: '#App.SignIn', | |
| forgotPassword: 'ForgotPassword' | |
| }) | |
| const fetchMachine = Machine({ | |
| id: 'App', | |
| initial: 'LaunchScreen', | |
| states: { | |
| LaunchScreen: { | |
| on: { | |
| "": [ | |
| { | |
| target: 'Content', | |
| cond: 'isUserSignedIn' | |
| }, | |
| { | |
| target: "SignIn" | |
| } | |
| ] | |
| } | |
| }, | |
| SignIn: withScreenState({ | |
| ...SignInState, | |
| }), | |
| SignUp: withScreenState({ | |
| ...SignUpState, | |
| }), | |
| SelectSubscription: {}, | |
| SelectAccount: {}, | |
| CreateAccount: {}, | |
| DeleteAccount: {}, | |
| Content: {}, | |
| }, | |
| }, { | |
| guards: { | |
| isUserSignedIn: () => false | |
| }, | |
| }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment