Skip to content

Instantly share code, notes, and snippets.

@uidoyen
Last active September 3, 2022 13:56
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 uidoyen/39d18b0c9f45d96b1392c8cff6df8b65 to your computer and use it in GitHub Desktop.
Save uidoyen/39d18b0c9f45d96b1392c8cff6df8b65 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const loginMachine = Machine({
id: "form",
context: {
retries: 0
},
initial: "entering",
states: {
entering: {
on: {
SUBMIT: {
target: 'Submitting'
}
}
},
Submitting: {
on: {
RESOLVED:'success',
REJECTED: 'failure'
}
},
success: {
type: 'final'
},
failure: {
on: {
RETRY: {
target:'Submitting',
actions: 'incrementRetries'
}
}
}
}
},
{
actions: {
incrementRetries: assign((context, event) => context.retries + 1),
},
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment