Created
April 1, 2021 14:55
-
-
Save bigsweater/8e612677114b4a3f86c9f48288e1fb83 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 wfdlMachine = Machine({ | |
id: 'wfdl', | |
initial: 'checkCredentials', | |
states: { | |
checkCredentials: { | |
on: { | |
CREDENTIALS_VALID: { | |
target: 'fetchSkus' | |
}, | |
CREDENTIALS_INVALID: { | |
target: 'loginForm' | |
} | |
} | |
}, | |
fetchSkus: { | |
on: { | |
SKUS_REQUESTED: { | |
target: 'loading' | |
} | |
} | |
}, | |
loginForm: { | |
initial: 'idle', | |
on: { | |
SUBMIT: { | |
target: 'validateForm' | |
} | |
}, | |
states: { | |
idle: {}, | |
emailInvalid: {} | |
} | |
}, | |
validateForm: { | |
on: { | |
EMAIL_VALID: { | |
target: 'requestAuthentication' | |
}, | |
EMAIL_INVALID: { | |
target: 'loginForm.emailInvalid' | |
} | |
} | |
}, | |
requestAuthentication: { | |
on: { | |
AUTH_REQUESTED: 'loading', | |
} | |
}, | |
loading: { | |
on: { | |
CREDENTIALS_INVALID: { | |
target: 'loginForm' | |
}, | |
SKU_REQUEST_FULFILLED: { | |
target: 'skus' | |
}, | |
AUTH_REQUEST_FULFILLED: { | |
target: 'authSuccess' | |
}, | |
REQUEST_REJECTED: { | |
target: 'serverError' | |
} | |
} | |
}, | |
skus: { | |
type: 'final' | |
}, | |
authSuccess: { | |
type: 'final' | |
}, | |
serverError: { | |
type: 'final' | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment