Skip to content

Instantly share code, notes, and snippets.

@MaelFr
Created May 19, 2020 13:35
Show Gist options
  • Save MaelFr/8a72e9d2ebef81cb26fe69b51cffac84 to your computer and use it in GitHub Desktop.
Save MaelFr/8a72e9d2ebef81cb26fe69b51cffac84 to your computer and use it in GitHub Desktop.

Revisions

  1. MaelFr created this gist May 19, 2020.
    27 changes: 27 additions & 0 deletions machine.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    const door = Machine({
    id: 'door',
    initial: 'locked',
    states: {
    locked: {
    on: {
    UNLOCK: 'unlocked'
    }
    },
    unlocked: {
    initial: 'closed',
    states: {
    closed: {
    on: {
    LOCK: '#door.locked',
    OPEN: 'opened'
    }
    },
    opened: {
    on: {
    CLOSE: 'closed'
    }
    }
    }
    }
    }
    })