Skip to content

Instantly share code, notes, and snippets.

@GeneralistDev
Last active February 24, 2020 17:30
Show Gist options
  • Save GeneralistDev/9f612f60247ed29546fbe05f472ea558 to your computer and use it in GitHub Desktop.
Save GeneralistDev/9f612f60247ed29546fbe05f472ea558 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 needsTwoFactor = () => {
return true;
};
const needsChangePassword = () => {
return true;
};
const needsEnrollment = () => {
return true;
};
const fetchMachine = Machine({
id: 'auth',
initial: 'login',
states: {
login: {
on: {
SUCCESS: [
{
target: 'twofactor',
cond: needsTwoFactor
},
{
target: 'changepassword',
cond: needsChangePassword
},
{
target: 'enrollment',
cond: needsEnrollment
},
{
target: 'success'
}
]
}
},
twofactor: {
on: {
SUCCESS: [
{
target: 'changepassword',
cond: needsChangePassword
},
{
target: 'enrollment',
cond: needsEnrollment
},
{
target: 'success'
}
]
}
},
changepassword: {
on: {
SUCCESS: [
{
target: 'enrollment',
cond: needsEnrollment
},
{
target: 'success'
}
]
}
},
enrollment: {
on: {
SUCCESS: [
{
target: 'success'
}
]
}
},
success: {
type: 'final'
},
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment