Skip to content

Instantly share code, notes, and snippets.

@robinandeer
Created May 5, 2020 11:44
Show Gist options
  • Save robinandeer/4616d057bbb26f73ee1cd2666df1facf to your computer and use it in GitHub Desktop.
Save robinandeer/4616d057bbb26f73ee1cd2666df1facf 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 welcomeMachine = Machine({
id: 'welcome',
initial: 'idle',
context: {
tokens: null,
},
states: {
idle: {
on: {
AUTHORIZE: 'authorizing',
SHOW_COUNTRY_SELECTOR: 'countrySelect',
},
},
countrySelect: {
on: {
HIDE_COUNTY_SELECTOR: 'idle',
},
},
authorizing: {
invoke: {
id: 'authorize',
src: 'authorize',
onDone: {
target: 'validatingUser',
actions: assign({ tokens: (_, event) => event.data }),
},
onError: {
target: 'idle',
},
},
},
validatingUser: {
invoke: {
id: 'validateUser',
src: 'validateUser',
onDone: {
target: 'idle',
},
onError: {
target: 'failure',
},
},
},
failure: {
on: {
DISMISS: 'idle',
},
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment