Skip to content

Instantly share code, notes, and snippets.

@trabianmatt
Last active December 28, 2020 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trabianmatt/3fa6c9d7ee5914e6a1a4cf60631c9f44 to your computer and use it in GitHub Desktop.
Save trabianmatt/3fa6c9d7ee5914e6a1a4cf60631c9f44 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine({
id: 'fetch',
initial: 'idle',
context: {
retries: 0,
},
states: {
idle: {
on: {
OPEN: 'gettingUserIdFromDatabase',
},
},
gettingUserIdFromDatabase: {
on: {
PRESENT: 'reconcilingAccounts',
NOT_PRESENT: 'checkingEnrollment',
},
},
checkingEnrollment: {
on: {
ENROLLED: 'reconcilingAccounts',
NOT_ENROLLED: 'enrollment',
},
},
reconcilingAccounts: {
initial: 'fetchingFundingSources',
onDone: 'sso',
states: {
fetchingFundingSources: {
onDone: 'comparingFundingSources',
},
comparingFundingSources: {
on: {
MATCH: 'complete',
NO_MATCH: 'addingMissingFundingSources',
},
},
addingMissingFundingSources: {
on: {
COMPLETE: 'complete',
},
},
complete: {
type: 'final',
},
},
},
sso: {
initial: 'fetchingSSO',
states: {
fetchingSSO: {
onDone: 'presentingSSO',
},
presentingSSO: {},
},
},
enrollment: {
onDone: 'sso',
initial: 'presentingTermsAndConditions',
states: {
presentingTermsAndConditions: {
on: {
ACCEPT: 'savingTermsAndConditions',
},
},
savingTermsAndConditions: {
onDone: 'addingConsumer',
},
addingConsumer: {
onDone: 'addingFundingProfile',
},
addingFundingProfile: {
onDone: 'complete',
},
complete: {
type: 'final',
},
},
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment