Skip to content

Instantly share code, notes, and snippets.

@pyoner
Last active December 27, 2019 05:28
Show Gist options
  • Save pyoner/8ff26de4e943a6b7d35905a2b0359170 to your computer and use it in GitHub Desktop.
Save pyoner/8ff26de4e943a6b7d35905a2b0359170 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const authMachine = Machine({
id: 'auth',
initial: 'nonAuth',
context: {
isAuth: false,
},
states: {
nonAuth: {
initial: 'idle',
states: {
idle: {
on: {
LOGIN: '#auth.auth',
REGISTRATION: 'registration'
}
},
registration: {
on: {
LOGIN: '#auth.auth'
}
}
}
},
auth: {
entry: assign({
isAuth: () => true
}),
exit: assign({
isAuth: () => false
}),
on: {
LOGOUT: 'nonAuth'
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment