Last active
September 3, 2022 13:56
-
-
Save uidoyen/39d18b0c9f45d96b1392c8cff6df8b65 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 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