Skip to content

Instantly share code, notes, and snippets.

@jaetask
Last active March 26, 2020 17:20
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 jaetask/0ed17128d65856bce1a6879933549f90 to your computer and use it in GitHub Desktop.
Save jaetask/0ed17128d65856bce1a6879933549f90 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - assign
// - send
// - raise
// - actions
const loginMachine = Machine({
id: 'login_machine',
initial: 'idle',
context: {
documentType: '',
retries: 0,
canRetry: false,
},
states: {
idle: {
on: {
AUTHENTICATE: 'authenticating'
}
},
authenticating: {
on: {
AUTHENTICATED: 'success',
AUTHENTICATION_ERROR: 'failure'
}
},
success: {
},
failure: {
on: {
RETRY: {
target: 'authenticating',
actions: assign({
retries: (context, event) => context.retries + 1
})
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment