Skip to content

Instantly share code, notes, and snippets.

@LevelbossMike
Created August 20, 2020 20:20
Show Gist options
  • Select an option

  • Save LevelbossMike/4b7907209faa9cf2367d455b2e7e6178 to your computer and use it in GitHub Desktop.

Select an option

Save LevelbossMike/4b7907209faa9cf2367d455b2e7e6178 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: 'wizard',
initial: 'unknown',
states: {
unknown: {
on: {
'': [
{ target: 'a', cond: 'isA'},
{ target: 'b', cond: 'isB' },
{ target: 'c', cond: 'isC' }
]
}
},
a: {
on: {
NEXT: {
target: 'unknown',
actions: ['updateQueryB']
}
}
},
b: {
on: {
NEXT: {
target: 'unknown',
actions: ['updateQueryC']
},
PREV: {
target: 'unknown',
actions: ['updateQueryA']
}
}
},
c: {
on: {
PREV: {
target: 'unknown',
actions: ['updateQueryA']
}
}
}
}
}, {
guards: {
isA() {},
isB() {},
isC() {}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment