Last active
August 26, 2020 19:12
-
-
Save n8io/f068d7cdccd7dd061c7a2900436f9939 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
const Guard = { | |
EMAIL_BAD_FORMAT: () => true, | |
PASSWORD_BAD_FORMAT: () => true, | |
EMPTY: () => true, | |
} | |
const fetchMachine = Machine({ | |
id: 'login', | |
initial: 'init', | |
states: { | |
init: { | |
on: { | |
EMAIL_INPUT_FOCUS: 'emailInputFocused', | |
PASSWORD_INPUT_FOCUS: 'passwordInputFocused', | |
}, | |
}, | |
emailInputFocused: { | |
on: { | |
TYPE_EMAIL: [ | |
{ | |
cond: Guard.EMPTY, | |
target: 'emailInputFocused.empty', | |
}, | |
{ | |
cond: Guard.EMAIL_BAD_FORMAT, | |
target: 'emailInputFocused.badFormat', | |
}, | |
'valid' | |
], | |
}, | |
states: { | |
empty: {}, | |
badFormat: {}, | |
valid: {}, | |
}, | |
}, | |
passwordInputFocused: { | |
on: { | |
TYPE_PASSWORD: [ | |
{ | |
cond: Guard.EMPTY, | |
target: 'passwordInputFocused.empty', | |
}, | |
{ | |
cond: Guard.PASSWORD_BAD_FORMAT, | |
target: 'passwordInputFocused.badFormat', | |
}, | |
'valid' | |
], | |
}, | |
states: { | |
empty: {}, | |
badFormat: {}, | |
valid: {}, | |
}, | |
}, | |
submitting: { | |
}, | |
}, | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment