Last active
October 26, 2020 17:14
-
-
Save bholmesdev/f0320383c07954c0ad8d902bcf941d55 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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