Skip to content

Instantly share code, notes, and snippets.

@betocantu93
Created October 20, 2020 16:14
Show Gist options
  • Select an option

  • Save betocantu93/d18df9a19c170ff32835d9d2be174e61 to your computer and use it in GitHub Desktop.

Select an option

Save betocantu93/d18df9a19c170ff32835d9d2be174e61 to your computer and use it in GitHub Desktop.

Revisions

  1. betocantu93 created this gist Oct 20, 2020.
    102 changes: 102 additions & 0 deletions machine.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,102 @@

    // Available variables:
    // - Machine
    // - interpret
    // - assign
    // - send
    // - sendParent
    // - spawn
    // - raise
    // - actions
    // - XState (all XState exports)

    const fetchMachine = Machine({
    id: "action",
    initial: "created",
    states: {
    created: {
    on: {
    ASSIGN: "pending",
    CANCEL: "canceled",
    },
    meta: {
    ASSIGN: {},
    CANCEL: {
    type: "warn",
    icon: "cancel",
    },
    },
    },
    pending: {
    on: {
    START: "in_progress",
    CANCEL: "canceled",
    },
    meta: {
    START: {},
    CANCEL: {
    type: "warn",
    icon: "cancel",
    },
    },
    },
    in_progress: {
    on: {
    PROPOSE: "ready",
    CANCEL: "canceled",
    },
    meta: {
    PROPOSE: {
    type: "primary",
    },
    CANCEL: {
    type: "warn",
    icon: "cancel",
    },
    },
    },
    ready: {
    on: {
    DECLINE: "declined",
    CLOSE: "done",
    CANCEL: "canceled",
    },
    meta: {
    DECLINE: {},
    CLOSE: {},
    CANCEL: {
    type: "warn",
    icon: "cancel",
    },
    },
    },
    declined: {
    on: {
    CORRECT: "in_progress",
    CANCEL: "canceled",
    },
    meta: {
    CORRECT: {},
    CANCEL: {
    type: "warn",
    icon: "cancel",
    },
    },
    },
    canceled: {
    on: {
    ENABLE: "created",
    },
    meta: {
    ENABLE: {
    icon: "restore",
    },
    },
    },
    done: {
    type: "final",
    },
    }
    }
    );