Skip to content

Instantly share code, notes, and snippets.

@rootart
Last active May 3, 2020 21:56
Show Gist options
  • Select an option

  • Save rootart/d1ecbba7c2d4b5c6cfc76d82a2773e24 to your computer and use it in GitHub Desktop.

Select an option

Save rootart/d1ecbba7c2d4b5c6cfc76d82a2773e24 to your computer and use it in GitHub Desktop.

Revisions

  1. Vasyl Dizhak revised this gist May 3, 2020. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions machine.js
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,16 @@ const triathlonMachine = Machine(
    {
    id: 'triathlonMachine',
    initial: 'idle',
    context: {
    startTime: null,
    transitionOneStart: null,
    cyclingLegStart: null,
    transitionTwoStart: null,
    runningLegStart: null,
    finishEnd: null,
    dnfTime: null,
    },

    on: {
    PULL_OUT: 'dnf',
    cond: () => {}
  2. Vasyl Dizhak revised this gist May 3, 2020. 1 changed file with 4 additions and 8 deletions.
    12 changes: 4 additions & 8 deletions machine.js
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,11 @@

    const triathlonMachine = Machine(
    {
    id: 'triathlonMachine',
    initial: 'idle',
    on: {
    PULL_OUT: 'dnf',
    cond: 'isActive'
    cond: () => {}
    },

    states: {
    @@ -31,18 +32,13 @@ const triathlonMachine = Machine(
    },
    running: {
    on: {
    FINISH: '#triathlonMachine.finishisActiveed',
    FINISH: '#triathlonMachine.finished',
    PULL_OUT: '#triathlonMachine.dnf',
    }
    }
    }
    }

    }
    },
    {
    guards: {
    isActive: function() {}
    }
    }
    );
    )
  3. Vasyl Dizhak created this gist May 3, 2020.
    48 changes: 48 additions & 0 deletions machine.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    const triathlonMachine = Machine(
    {
    id: 'triathlonMachine',
    initial: 'idle',
    on: {
    PULL_OUT: 'dnf',
    cond: 'isActive'
    },

    states: {
    idle: {
    on: {
    START: 'active.swimming',
    }
    },
    dnf: {},
    finished: {},
    active: {
    states: {
    swimming: {
    on: {
    TRANSITION: 'cycling',
    PULL_OUT: '#triathlonMachine.dnf',
    }
    },
    cycling: {
    on: {
    TRANSITION: 'running',
    PULL_OUT: '#triathlonMachine.dnf',
    }
    },
    running: {
    on: {
    FINISH: '#triathlonMachine.finishisActiveed',
    PULL_OUT: '#triathlonMachine.dnf',
    }
    }
    }
    }

    }
    },
    {
    guards: {
    isActive: function() {}
    }
    }
    );