Skip to content

Instantly share code, notes, and snippets.

@xJkit
Created June 16, 2021 09:08
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 xJkit/4e45c6eefea077ff69815fc284e2a2d5 to your computer and use it in GitHub Desktop.
Save xJkit/4e45c6eefea077ff69815fc284e2a2d5 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - MachinebeginAth
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const beginAuth = () => new Promise((resolve, reject) => {
setTimeout(() => {
resolve({
userId: 'joey54780',
username: 'jay chung',
IDToken: 'asdasxcvds!@@!#',
})
}, 3000)
})
const authMachine = Machine({
id: 'auth',
initial: 'guest',
context: {
userId: '',
username: '',
IDToken: "",
},
states: {
guest: {
on: {
BEGIN_AUTH: {
target: 'logging',
}
}
},
logging: {
invoke: {
src: beginAuth
},
on: {
FINISH_AUTH: {
target: 'logged',
}
}
},
logged: {}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment