Skip to content

Instantly share code, notes, and snippets.

@wlee221
Last active June 24, 2021 18:03
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 wlee221/3fb1458b6f466ef5fd6300e2e619831b to your computer and use it in GitHub Desktop.
Save wlee221/3fb1458b6f466ef5fd6300e2e619831b to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
Machine(
{
id: 'signUp',
initial: "edit",
exit: ["clearFormValues", "clearError"],
states: {
edit: {
id: "edit",
initial: "noError",
type: "parallel",
states: {
authError: {
initial: "none",
states: {
none: {},
error: {},
},
},
validationError: {
initial: "none",
states: {
none: {},
error: {},
},
on: {
INPUT: [
{
actions: ["handleInput", "clearPwMismatchError"],
cond: "pwMatches",
target: ".none",
},
{
actions: ["handleInput", "setPwMismatchError"],
target: ".error",
},
],
},
},
},
on: {
SUBMIT: {
target: "submit",
in: {
edit: {
validationError: "none",
},
},
},
},
},
submit: {
entry: "clearError",
invoke: {
src: "signUp",
onDone: {
actions: "setUser",
target: "resolved",
},
onError: {
actions: "setCognitoError",
target: "edit.authError.error",
},
},
},
resolved: {
type: "final",
},
},
},
{
guards: {
pwMatches: (context, event) => {
return false;
},
},
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment