Skip to content

Instantly share code, notes, and snippets.

@JamieMason
Created October 19, 2021 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JamieMason/cec46fae3f592e24abb1085f65bbd402 to your computer and use it in GitHub Desktop.
Save JamieMason/cec46fae3f592e24abb1085f65bbd402 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine(
{
initial: "evaluating",
states: {
evaluating: {
on: {
"done.invoke.loadAddressBook": [
{
cond: "hasAddresses",
target: "addressBookAndForm",
},
{ target: "addressFormOnly" },
],
"error.platform.loadAddressBook": "",
},
},
addressBookAndForm: {
type: "parallel",
states: {
addressBook: {},
addressFormWrapper: {
initial: "hidden",
states: {
hidden: {
on: {
ADD_NEW_ADDRESS: "visible",
},
},
visible: {},
},
},
},
},
addressFormOnly: {},
},
},
{
guards: {
hasAddresses() {
return false;
},
},
}
);
// const fetchMachine = Machine({
// type: "parallel",
// states: {
// addressBook: {},
// addressForm: {
// initial: "hidden",
// states: {
// hidden: {
// on: {
// ADD_NEW_ADDRESS: "visible",
// },
// },
// visible: {},
// },
// },
// },
// });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment