Skip to content

Instantly share code, notes, and snippets.

@dimsuz
Last active November 25, 2019 00:28
Show Gist options
  • Save dimsuz/f96833dea1b8774be65aee29bfefaf67 to your computer and use it in GitHub Desktop.
Save dimsuz/f96833dea1b8774be65aee29bfefaf67 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 loginStates = {
id: 'login_screen',
initial: 'login',
states: {
login: {
}
}
}
const otpStates = {
id: 'otp_screen',
initial: 'otp_intro',
states: {
otp_intro: {
on: {
'OTP_INTRO_CONTINUE': 'otp_input'
}
},
otp_input: {
}
}
}
const pinCreateStates = {
id: 'pin_create_screens',
initial: 'pin_intro',
states: {
pin_intro: {
on: {
'PIN_INTRO_CONTINUE': 'pin_create',
'BACK': 'dismissed'
}
},
pin_create: {
on: {
'BACK': 'pin_intro',
'PIN_CREATE_SUCCESS': 'success'
}
},
dismissed: {
type: 'final'
},
success: {
type: 'final'
}
}
}
const fetchMachine = Machine({
id: 'fetch',
initial: 'flow_login',
context: {
retries: 0
},
states: {
flow_login: {
on: {
'LOGIN_SUCCESS_OTP_REQUIRED': 'flow_otp',
'LOGIN_SUCCESS_OTP_NOT_REQUIRED': 'flow_pin_create'
},
...loginStates
},
flow_otp: {
on: {
'BACK': 'flow_login'
},
...otpStates
},
flow_pin_create: {
...pinCreateStates,
on: {
},
// TODO or to flow_login depending on who opened!
onDone: 'flow_otp'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment