Skip to content

Instantly share code, notes, and snippets.

@raphaelbadia
Created July 15, 2020 08:54
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 raphaelbadia/62f6604d1666e68272b3e6ccb5bf391a to your computer and use it in GitHub Desktop.
Save raphaelbadia/62f6604d1666e68272b3e6ccb5bf391a to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const mainMachine = Machine({
id: 'main',
initial: 'idle',
context: {
// retries: 0
},
states: {
idle: {
on: {
START: 'start'
}
},
error: {
// on: {
// RETRY: 'unauthorized'
// }
},
start: {
invoke: {
src: "getCachedCredentials",
onDone: { target: "login" },
onError: { target: "unauthorized", actions: "onError" },
}
},
unauthorized: {
on: {
LOGIN: 'login'
},
},
login: {
invoke: {
src: "proceedLogin",
onDone: { target: "working", actions: "onSuccess" },
onError: { target: "unauthorized", actions: "onError" },
}
},
working: {
states: {
},
},
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment