Skip to content

Instantly share code, notes, and snippets.

@datdoan
Created September 7, 2020 00:54
Show Gist options
  • Select an option

  • Save datdoan/1b7e547726310d996a72c748ad00eaf2 to your computer and use it in GitHub Desktop.

Select an option

Save datdoan/1b7e547726310d996a72c748ad00eaf2 to your computer and use it in GitHub Desktop.

Revisions

  1. datdoan created this gist Sep 7, 2020.
    41 changes: 41 additions & 0 deletions machine.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@

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

    const statusMachine = Machine({
    id: 'status',
    type: 'parallel',
    states: {
    closed: {
    initial: 'on',
    states: {
    on: {
    on: { TOGGLE_CLOSED: 'off' }
    },
    off: {
    on: { TOGGLE_CLOSED: 'on' }
    }
    }
    },
    open: {
    initial: 'on',
    states: {
    on: {
    on: { TOGGLE_OPEN: 'off' }
    },
    off: {
    on: { TOGGLE_OPEN: 'on' }
    }
    }
    },
    }
    });