Last active
September 14, 2021 04:07
-
-
Save akshaypilankar/1e567cff699c55a1ce366eec721b5cd9 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 fetchMachine = Machine({ | |
id: 'app', | |
initial: 'init', | |
context: { | |
user:{}, | |
isLoggedIn:false | |
}, | |
states: { | |
init:{ | |
on: [ { | |
cond: 'isLoggedIn', | |
target: 'profile' | |
}, | |
{ | |
cond: '!isLoggedIn', | |
target: 'auth' | |
} | |
]}, | |
auth:{ | |
initial: 'login', | |
states:{ | |
login: { | |
on: { | |
ENTER_EMAIL: { | |
actions: 'cacheEmail' | |
}, | |
ENTER_PASSWORD: { | |
actions: 'cachePassword' | |
}, | |
SUBMIT: [ | |
{ | |
cond: 'isLoggedIn', | |
target: '#app.profile' | |
} | |
], | |
SIGNUP:'signup', | |
} | |
}, | |
signup:{ | |
on: { | |
ENTER_FULL_NAME: { | |
actions: 'cacheFullName' | |
}, | |
ENTER_EMAIL: { | |
actions: 'cacheEmail' | |
}, | |
ENTER_PASSWORD: { | |
actions: 'cachePassword' | |
}, | |
REENTER_PASSWORD: { | |
actions: 'cacheReenterPassword' | |
}, | |
SUBMIT: [ | |
{ | |
cond: 'isLoggedIn', | |
target: '#app.profile' | |
} | |
], | |
LOGIN:'login' | |
} | |
}, | |
} | |
}, | |
profile: { | |
type: 'final' | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment