Skip to content

Instantly share code, notes, and snippets.

@samwightt
Created April 26, 2021 17:45
Show Gist options
  • Save samwightt/7bef3d8edb3fce9a9f9373b1ccd9353f to your computer and use it in GitHub Desktop.
Save samwightt/7bef3d8edb3fce9a9f9373b1ccd9353f 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({
initial: "pending",
id: 'bootstrapEditor',
states: {
pending: {
on: {
BEGIN_LOAD: "loading",
},
},
loading: {
type: "parallel",
onDone: "loaded",
states: {
loadPageData: {
initial: "loadPage",
states: {
loadPage: {
invoke: {
src: "fetchPageData",
onDone: {
target: "loadPageComponents",
actions: ["setPageData"],
},
onError: "error",
},
},
loadPageComponents: {
invoke: {
src: "loadPageComponentCode",
onDone: {
target: "complete",
actions: ["setPageComponentCode"],
},
onError: "error",
},
},
error: {
on: {
'': '#error'
}
},
complete: {
type: "final",
},
},
},
loadComponents: {
initial: "getComponents",
states: {
getComponents: {
invoke: {
src: "fetchAllComponents",
onDone: {
target: "fetchComponentCode",
actions: ["setAllComponentData"],
},
onError: "error",
},
},
fetchComponentCode: {
invoke: {
src: "fetchComponentCode",
onDone: {
target: "complete",
actions: ["setAllComponentCode"],
},
onError: "error",
},
},
error: {
on: {
'': '#error'
}
},
complete: {
type: "final",
},
},
},
},
},
loaded: {
type: "final",
},
error: {
id: "error",
type: "final",
},
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment