Skip to content

Instantly share code, notes, and snippets.

@RainerAtSpirit
Last active November 22, 2019 16:28
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 RainerAtSpirit/a32510d4af8710ce4ac8ea0ece42bf64 to your computer and use it in GitHub Desktop.
Save RainerAtSpirit/a32510d4af8710ce4ac8ea0ece42bf64 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: "categoriesMachine",
initial: "entry",
context: {
categoryMap: {},
categoryId: "",
actor: undefined,
actorMap: {},
level: 0,
result: {}
},
states: {
entry: {
initial: "init",
states: {
init: {
on: {
"": [{ target: "new", cond: "hasNoResult" }, { target: "edit" }]
}
},
new: {
entry: ["onLoadRoot"],
after: {
TIMEOUT: "#categoriesMachine.nextLevelLoaded"
}
},
edit: {
entry: ["setPartialCategoryMap"]
}
}
},
nextLevelLoaded: {},
selected: {
on: {
LOAD_NEXT_LEVEL: {
actions: "onUpdateCategoryMap"
}
},
after: {
TIMEOUT: "nextLevelLoaded"
}
}
},
on: {
SELECT: {
target: "selected",
actions: "onSelect"
},
RESET: {
target: "entry.new"
}
}
},
{
guards: {
hasNoResult: () => false
},
delays: {
TIMEOUT: 2000
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment