Skip to content

Instantly share code, notes, and snippets.

@Sheldonfrith
Last active December 15, 2020 04:12
Show Gist options
  • Save Sheldonfrith/9c34ef52dccb3101920a7e78d2f15cb2 to your computer and use it in GitHub Desktop.
Save Sheldonfrith/9c34ef52dccb3101920a7e78d2f15cb2 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 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