Last active
December 15, 2020 04:12
-
-
Save Sheldonfrith/9c34ef52dccb3101920a7e78d2f15cb2 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or 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 globalStates = { | |
initial: 'loggedOut', | |
states: { | |
loggedIn: { | |
}, | |
loggedOut: { | |
} | |
} | |
} | |
const welcomeStates = { | |
initial: 'idle', | |
states: { | |
idle: { | |
} | |
} | |
} | |
const questionaireStates = { | |
initial: 'simpleOrComplex', | |
context: { | |
retries: 0 | |
}, | |
states: { | |
simpleOrComplex:{ | |
on: { | |
SIMPLE: 'tutorial', | |
COMPLEX: 'tutorial', | |
} | |
}, | |
tutorial: { | |
on: { | |
SKIP: 'progressOverview', | |
FINISH: 'progressOverview', | |
} | |
}, | |
progressOverview:{ | |
on: { | |
START: 'categoryOverview' | |
} | |
}, | |
categoryOverview:{ | |
on: { | |
SKIP: 'categoryOverview', | |
BACK: 'progressOverview', | |
CONTINUE: 'questionIsImportant', | |
} | |
}, | |
questionIsImportant:{ | |
on: { | |
YES: 'form', | |
NO: 'questionIsImportant', | |
} | |
}, | |
form: { | |
on: { | |
ISNOTIMPORTANT: 'questionIsImportant', | |
COMPLETE: 'questionIsImportant' | |
}, | |
} | |
} | |
}; | |
const resultsStates = { | |
initial: 'loading', | |
context: { | |
}, | |
states: { | |
loading: { | |
on: { | |
SUCCESS: 'loaded' | |
} | |
}, | |
loaded: { | |
} | |
} | |
} | |
const appMachine = Machine({ | |
id: 'app', | |
initial: 'welcomePage', | |
context: { | |
}, | |
states: { | |
welcomePage:{ | |
...welcomeStates | |
}, | |
questionaire: { | |
...questionaireStates | |
}, | |
results: { | |
...resultsStates | |
} | |
} | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment