Last active
December 27, 2019 05:28
-
-
Save pyoner/8ff26de4e943a6b7d35905a2b0359170 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
// 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