Created
April 21, 2021 19:44
-
-
Save thorgas/61368b468f7cc7dc2f93e85a844b6cf1 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 CreateAccountStates = { | |
| loadingPrerequisites : 'loadingPrerequisites', | |
| createAccount : 'createAccount', | |
| addFirstPage : 'addFirstPage', | |
| addSecondPage : 'addSecondPage', | |
| loading : 'loading', | |
| error : 'error', | |
| finished : 'finished', | |
| } | |
| const CreateAccountEvents = { | |
| DONE : 'DONE', | |
| SUBMIT : 'SUBMIT', | |
| LOADING : 'LOADING', | |
| CREATE_ACCOUNT : 'CREATE_ACCOUNT', | |
| ADD_FIRST_PAGE : 'ADD_FIRST_PAGE', | |
| ERROR : 'ERROR', | |
| } | |
| const fetchMachine = Machine({ | |
| id: 'createMangoAccount', | |
| initial: CreateAccountStates.loadingPrerequisites, | |
| context: { | |
| error: false, | |
| errorMessage: '', | |
| profile: null, | |
| }, | |
| states: { | |
| loadingPrerequisites: { | |
| on: { | |
| DONE: { | |
| target: 'createAccount', | |
| actions: assign({ profile: (_, profile) => profile }), | |
| }, | |
| }, | |
| }, | |
| createAccount: { | |
| on: { | |
| SUBMIT: { | |
| target: 'loading', | |
| // TODO remap birthday | |
| actions: assign({ profile: (_, profile) => profile }), | |
| }, | |
| }, | |
| }, | |
| addFirstPage: { | |
| on: { | |
| DONE: 'addSecondPage', | |
| }, | |
| }, | |
| addSecondPage: { | |
| on: { DONE: 'finished' }, | |
| }, | |
| loading: { | |
| on: { CREATE_ACCOUNT: 'createAccount', ADD_FIRST_PAGE: 'addFirstPage', ERROR: 'error' }, | |
| }, | |
| error: { | |
| type: 'final', | |
| }, | |
| finished: { | |
| type: 'final', | |
| }, | |
| }, | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment