Skip to content

Instantly share code, notes, and snippets.

@betocantu93
Last active September 18, 2020 16:57
Show Gist options
  • Save betocantu93/8c5b50bc7af67528990ae0c305c27c46 to your computer and use it in GitHub Desktop.
Save betocantu93/8c5b50bc7af67528990ae0c305c27c46 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: "action",
initial: "boot",
states: {
boot: {
always: [
{ target: "created", cond: "isCreated" },
{ target: "pending", cond: "isPending" },
{ target: "in_progress", cond: "isInProgress" },
{ target: "ready", cond: "isReady" },
{ target: "declined", cond: "isDeclined" },
{ target: "canceled", cond: "isCanceled" },
{ target: "done", cond: "isDone" },
],
},
created: {
on: {
ASSIGN: "pending",
CANCEL: "canceled",
},
meta: {
ASSIGN: {},
CANCEL: {
warn: true,
icon: "cancel",
},
},
},
pending: {
on: {
START: "in_progress",
CANCEL: "canceled",
},
meta: {
START: {},
CANCEL: {
warn: true,
icon: "cancel",
},
},
},
in_progress: {
on: {
PROPOSE: "ready",
CANCEL: "canceled",
},
meta: {
PROPOSE: {},
CANCEL: {
warn: true,
icon: "cancel",
},
},
},
ready: {
on: {
DECLINE: "declined",
CLOSE: "done",
CANCEL: "canceled",
},
meta: {
DECLINE: {},
CLOSE: {},
CANCEL: {
warn: true,
icon: "cancel",
},
},
},
declined: {
on: {
CORRECT: "in_progress",
CANCEL: "canceled",
},
meta: {
CORRECT: {},
CANCEL: {
warn: true,
icon: "cancel",
},
},
},
canceled: {
on: {
ENABLE: "created",
},
meta: {
ENABLE: {
icon: "restore",
},
},
},
done: {
type: "final",
},
},
},{ guards: { isCreated: () => true}});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment