Skip to content

Instantly share code, notes, and snippets.

@kaze
Last active September 14, 2020 04:45
Show Gist options
  • Save kaze/623d75154a2e220396a645c08b39eabe to your computer and use it in GitHub Desktop.
Save kaze/623d75154a2e220396a645c08b39eabe to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const login_activate_signal = 'login.activate';
const login_deactivate_signal = 'login.deactivate';
const register_activate_signal = 'register.activate';
const register_deactivate_signal = 'register.deactivate';
const send_activate_login = () => {
send({ type: login_activate_signal })
};
const send_deactivate_login = () => {
send({ type: login_deactivate_signal })
};
const send_activate_register= () => {
send({ type: register_activate_signal })
};
const send_deactivate_register = () => {
send({ type: register_deactivate_signal })
};
const auth_machine = Machine({
id: 'auth',
initial: 'login',
context: {},
states: {
login: {
on: {
register: {
target: 'register',
},
},
entry: [ 'send_activate_login', ],
exit: [ 'send_deactivate_login', ],
},
register: {
entry: [ 'send_activate_register', ],
exit: [ 'send_deactivate_register', ],
on: {
login: {
target: 'login',
},
},
},
},
}, {
actions: {
send_activate_login,
send_deactivate_login,
send_activate_register,
send_deactivate_register,
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment