Skip to content

Instantly share code, notes, and snippets.

@montogeek
Created August 7, 2020 13:33
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 montogeek/3d73baed138c6149b531f0ea3059c5c0 to your computer and use it in GitHub Desktop.
Save montogeek/3d73baed138c6149b531f0ea3059c5c0 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 fetchMachine = Machine({
id: 'training',
initial: 'idle',
states: {
idle: {
id: 'idle',
on: {
showHealthCheck: 'healthCheck',
},
},
healthCheck: {
initial: 'idle',
states: {
idle: {
on: {
agree: '#overview',
disagree: 'notFeelingWell',
},
},
notFeelingWell: {
on: {
agree: '#overview',
},
},
},
},
overview: {
id: 'overview',
on: {
continue: 'exerciseInfo',
quit: 'quit',
},
},
exerciseInfo: {
id: 'exerciseInfo',
initial: 'idle',
on: {
start: 'countdown',
},
states: {
idle: {
on: {
showInstructions: 'instructions',
showSettings: 'settings',
skip: '#skip',
quit: '#quit'
},
},
instructions: {
on: {
close: 'idle',
},
},
// No idea if saving settings closes the dialog or not
settings: {
on: {
close: 'idle',
},
},
},
},
skip: {
id: 'skip',
initial: 'idle',
states: {
idle: {
on: {
agree: '#exerciseInfo',
disagree: '#exerciseInfo',
},
},
},
},
quit: {
id: 'quit',
initial: 'idle',
states: {
idle: {
on: {
agree: '#idle',
disagree: '#exerciseInfo',
},
},
},
},
countdown: {
on: {
quit: '#quit', // On confirmation goes to start training
finish: 'exerciseExecution',
},
},
exerciseExecution: {
initial: 'idle',
states: {
idle: {
on: {
pause: 'paused',
finishSet: 'countdown',
finishExercise: 'success',
finishBeforeLastExercise: 'success.beforeLast', // Rename to encouraing.
finishAllExercises: 'success.complete',
skip: '#skip', // Resumes goes back to execution.
quit: '#quit', // Quit and resume goes back here.
},
},
paused: {
on: {
continue: 'idle',
},
},
countdown: {
on: {
// quit: "#idle", // On confirmation goes to start training
finish: 'idle',
},
},
success: {
initial: 'general',
states: {
general: {
on: {
// quit: "#idle", // On confirmation goes to start training
continue: '#exerciseInfo',
},
},
beforeLast: {
on: {
// quit: "#idle", // On confirmation goes to start training
continue: '#exerciseInfo',
},
},
complete: {
on: {
// quit: "#idle", // On confirmation goes to start training
continue: '#idle',
},
},
},
},
},
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment