Skip to content

Instantly share code, notes, and snippets.

@bholmesdev
Last active October 26, 2020 17:14
Show Gist options
  • Save bholmesdev/f0320383c07954c0ad8d902bcf941d55 to your computer and use it in GitHub Desktop.
Save bholmesdev/f0320383c07954c0ad8d902bcf941d55 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: 'configure',
initial: 'idle',
context: {
tradeInToggled: false,
},
states: {
idle: {
on: {
FORM_ERRORS: {
actions: 'focusErrors',
},
SUBMIT: {
target: 'submitting',
actions: 'submit',
},
TOGGLE_TRADE_IN: [
{
cond: context => context.tradeInToggled === false,
actions: [
'trackTradeInAnalytics',
assign({
tradeInToggled: true,
}),
],
},
{
actions: assign({
tradeInToggled: false,
}),
},
],
},
},
submitting: {
on: {
ADD_TO_CART_EXCEPTION: 'idle',
},
},
// will never have a "submitted" state!
// redux sagas will redirect you to the packages page on success
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment