Last active
March 18, 2021 18:56
-
-
Save christianjuth/42dd751e28b66a01538741a67b60c3f0 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains 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: 'checkout', | |
initial: 'cartLoading', | |
context: { | |
cart: {}, | |
error: '' | |
}, | |
states: { | |
cartLoading: { | |
on: { | |
CARD_LOADED: 'dataEntry', | |
CART_LOADING_FAILED: 'cartLoadingFailed' | |
} | |
}, | |
cartLoadingFailed: { | |
type: 'final' | |
}, | |
dataEntry: { | |
on: { | |
KEYBOARD_INPUT: 'dataEntry', | |
ADD_PROMO_CODE: 'promoCodeFetching', | |
ADD_CARD: 'cardAdding', | |
SUBMIT: 'submitting' | |
} | |
}, | |
error: { | |
on: { | |
KEYBOARD_INPUT: 'dataEntry', | |
ADD_PROMO_CODE: 'promoCodeFetching', | |
ADD_CARD: 'cardAdding' | |
} | |
}, | |
promoCodeFetching: { | |
on: { | |
PROMO_CODE_SUCCESS: 'dataEntry', | |
PROMO_CODE_FAILURE: 'error' | |
} | |
}, | |
cardAdding: { | |
on: { | |
CARD_ADDING_SUCCESS: 'dataEntry', | |
CARD_ADDING_FAILURE: 'error' | |
} | |
}, | |
submitting: { | |
on: { | |
SUBMITTING_SUCCESS: 'done', | |
SUBMITTING_ERROR: 'error' | |
} | |
}, | |
done: { | |
type: 'final' | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment