Created
May 5, 2020 11:44
-
-
Save robinandeer/4616d057bbb26f73ee1cd2666df1facf to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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