Skip to content

Instantly share code, notes, and snippets.

@ksm
Created Sep 29, 2020
Embed
What would you like to do?
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const signUpMachine = Machine({
id: 'sign-up-flow',
initial: 'invite_code',
context: {
invite_code: null,
phone_number: null,
email: null
},
states: {
invite_code: {
on: {
ENTER_CODE: 'phone_number',
NO_CODE: 'waitlist'
}
},
phone_number: {
on: {
ENTER_PHONE: 'email',
}
},
email: {
on: {
ENTER_EMAIL: 'password',
// now if email exists or not depends
}
},
password: {
on: {
ENTER_PASSWORD: 'logged_in_home'
}
},
logged_in_home: {
type: 'final'
},
waitlist: {
on: {
ENTER_EMAIL: 'waitlist_success'
}
},
waitlist_success: {}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment