Skip to content

Instantly share code, notes, and snippets.

@n8io
Last active August 26, 2020 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save n8io/f068d7cdccd7dd061c7a2900436f9939 to your computer and use it in GitHub Desktop.
Save n8io/f068d7cdccd7dd061c7a2900436f9939 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
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