Skip to content

Instantly share code, notes, and snippets.

@LevelbossMike
Last active August 20, 2020 20:07
Show Gist options
  • Select an option

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

Select an option

Save LevelbossMike/4c66d7b74e205037eeb60b1726f2f967 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: ['setQueryB']
}
}
},
b: {
on: {
NEXT: {
target: 'unknown', actions: ['setQueryC']
},
PREV: {
target: 'unknown', actions: ['setQueryA']
}
}
},
c: {
on: {
PREV: {
target: 'unknown', actions: ['setQueryB']
}
}
}
}
}, {
guards: {
isA() {},
isB() {},
isC() {}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment