Skip to content

Instantly share code, notes, and snippets.

@aeschylus
Last active August 17, 2021 18:43
Show Gist options
  • Save aeschylus/1443cb368c7bcd37cf30d1bd94f44dc5 to your computer and use it in GitHub Desktop.
Save aeschylus/1443cb368c7bcd37cf30d1bd94f44dc5 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 routingMachine = Machine({
id: 'overworld',
initial: 'landingPage',
context: {
retries: 0
},
states: {
landingPage: {
on: {
NAV_TO_SIGNUP: 'signingUp',
NAV_TO_LOGIN: 'loggingIn'
}
},
signingUp: {
type: 'parallel',
on: {
SUBMIT: 'initialWelcome',
REJECT: '.fillingOut'
},
states: {
type: 'parallel',
fillingOut: {
},
validating: {
states: {
valid: {
},
invalid: {
},
failure: {
on: {
RETRY: {
target: 'invalid',
actions: assign({
retries: (context, event) => context.retries + 1
})
}
}}
}
}
}
},
loggingIn: {
initial: 'confirming',
on: {
SUBMIT: '.confirming',
NAV_TO_DASHBOARD: 'dashboard'
},
states: {
confirming: {
on: {
SUCCESS: '#overworld.initialWelcome'
}
}
}
},
initialWelcome: {
on: {
CONFIRM_EMAIL: 'dashboard'
}
},
dashboard: {
on: {
NAV_TO_EXERCISES: 'studying'
}
},
studying: {
on: {
QUIT: 'dashboard',
COMPLETE: 'reviewingSession'
}
},
reviewingSession: {
on: {
CONTINUE: 'studying',
QUIT: 'dashboard'
}
},
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment