Skip to content

Instantly share code, notes, and snippets.

@saschwarz
Last active March 8, 2020 00:56
Show Gist options
  • Select an option

  • Save saschwarz/12be236f588172dee0282e48ff02e0b3 to your computer and use it in GitHub Desktop.

Select an option

Save saschwarz/12be236f588172dee0282e48ff02e0b3 to your computer and use it in GitHub Desktop.

Revisions

  1. saschwarz renamed this gist Mar 8, 2020. 1 changed file with 0 additions and 11 deletions.
    11 changes: 0 additions & 11 deletions machine.js → minimal-traffic-light-machine.js
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,4 @@

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

    const trafficLightMachine = Machine({
    id: 'traffic-light',
    initial: 'green',
  2. saschwarz created this gist Mar 7, 2020.
    37 changes: 37 additions & 0 deletions machine.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@

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

    const trafficLightMachine = Machine({
    id: 'traffic-light',
    initial: 'green',
    context: {
    retries: 0
    },
    states: {
    green: {
    on: {
    TIME: 'yellow'
    }
    },
    yellow: {
    on: {
    TIME: 'red'
    }
    },
    red: {
    on: {
    TIME: 'green'
    }
    },
    }
    });