Skip to content

Instantly share code, notes, and snippets.

@patrickporto
Last active April 7, 2020 15:14
Show Gist options
  • Save patrickporto/cb82c70897e30963686c56337635c79b to your computer and use it in GitHub Desktop.
Save patrickporto/cb82c70897e30963686c56337635c79b 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 postCardMachine = Machine({
id: "postCard",
initial: "idle",
states: {
resolved: {
on: { PENDING: "pending" },
type: "parallel",
states: {
size: {
initial: "expanded",
states: {
expanded: {
on: { SHRINK: "shrinked" },
},
shrinked: {
on: { EXPAND: "expanded" },
},
}
},
status: {
initial: "staged",
states: {
staged: {
on: { DRAFT: "draft", PUBLISH: "published" },
},
published: {
on: { DRAFT: "draft", CREATE: "staged", UPDATE: "staged" },
},
draft: {
on: {
PUBLISH: "published", CREATE: "staged", UPDATE: "staged"
},
},
}
},
operation: {
initial: "idle",
states: {
idle: {
on: { UPDATE: "update", CREATE: "create" },
},
create: {
on: { PUBLISH: "idle", DRAFT: "idle" },
},
update: {
on: { PUBLISH: "idle", DRAFT: "idle" },
},
}
}
},
},
pending: {
on: {
RESOLVED: "resolved",
},
},
idle: {
on: {
PENDING: "pending",
RESOLVED: "resolved",
},
},
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment