Skip to content

Instantly share code, notes, and snippets.

@xiaojundebug
Last active April 11, 2022 09:13
Show Gist options
  • Select an option

  • Save xiaojundebug/e7a996019c3a16f26589a401109390a0 to your computer and use it in GitHub Desktop.

Select an option

Save xiaojundebug/e7a996019c3a16f26589a401109390a0 to your computer and use it in GitHub Desktop.

Revisions

  1. xiaojundebug revised this gist Apr 11, 2022. 1 changed file with 0 additions and 5 deletions.
    5 changes: 0 additions & 5 deletions machine.js
    Original file line number Diff line number Diff line change
    @@ -50,8 +50,3 @@ const machine = Machine({
    }
    }
    });

    var service = interpret(machine)
    .onTransition(function (state) {
    console.log(state)
    }).start()
  2. xiaojundebug revised this gist Apr 11, 2022. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions machine.js
    Original file line number Diff line number Diff line change
    @@ -54,5 +54,4 @@ const machine = Machine({
    var service = interpret(machine)
    .onTransition(function (state) {
    console.log(state)
    })

    }).start()
  3. xiaojundebug revised this gist Apr 11, 2022. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion machine.js
    Original file line number Diff line number Diff line change
    @@ -55,5 +55,4 @@ var service = interpret(machine)
    .onTransition(function (state) {
    console.log(state)
    })
    .start()

  4. xiaojundebug revised this gist Apr 11, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion machine.js
    Original file line number Diff line number Diff line change
    @@ -53,7 +53,7 @@ const machine = Machine({

    var service = interpret(machine)
    .onTransition(function (state) {
    // console.log(state)
    console.log(state)
    })
    .start()

  5. xiaojundebug revised this gist Apr 11, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion machine.js
    Original file line number Diff line number Diff line change
    @@ -53,7 +53,7 @@ const machine = Machine({

    var service = interpret(machine)
    .onTransition(function (state) {
    console.log(state)
    // console.log(state)
    })
    .start()

  6. xiaojundebug revised this gist Apr 11, 2022. No changes.
  7. xiaojundebug revised this gist Apr 11, 2022. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion machine.js
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@ const adValid = (context, event) => {
    return !context.adSkipped
    };

    const fetchMachine = Machine({
    const machine = Machine({
    "initial": "空闲中",
    "context": {
    "adSkipped": true
    @@ -50,4 +50,10 @@ const adValid = (context, event) => {
    }
    }
    });

    var service = interpret(machine)
    .onTransition(function (state) {
    console.log(state)
    })
    .start()

  8. xiaojundebug revised this gist Apr 11, 2022. 1 changed file with 7 additions and 4 deletions.
    11 changes: 7 additions & 4 deletions machine.js
    Original file line number Diff line number Diff line change
    @@ -15,12 +15,12 @@ const adValid = (context, event) => {
    };

    const fetchMachine = Machine({
    "initial": "空闲",
    "initial": "空闲中",
    "context": {
    "adSkipped": true
    },
    "states": {
    "空闲": {
    "空闲中": {
    "on": {
    "广告": "广告中",
    "直播": "直播中",
    @@ -29,11 +29,13 @@ const adValid = (context, event) => {
    "广告中": {
    "on": {
    "跳过": "直播中",
    "空闲": "空闲中",
    }
    },
    "直播中": {
    "on": {
    "点播": "点播中"
    "点播": "点播中",
    "空闲": "空闲中",
    }
    },
    "点播中": {
    @@ -42,7 +44,8 @@ const adValid = (context, event) => {
    "target": "广告中",
    "cond": adValid
    },
    "直播": "直播中"
    "直播": "直播中",
    "空闲": "空闲中",
    }
    }
    }
  9. xiaojundebug revised this gist Apr 11, 2022. No changes.
  10. xiaojundebug revised this gist Apr 11, 2022. 1 changed file with 11 additions and 1 deletion.
    12 changes: 11 additions & 1 deletion machine.js
    Original file line number Diff line number Diff line change
    @@ -10,8 +10,15 @@
    // - actions
    // - XState (all XState exports)

    const adValid = (context, event) => {
    return !context.adSkipped
    };

    const fetchMachine = Machine({
    "initial": "空闲",
    "context": {
    "adSkipped": true
    },
    "states": {
    "空闲": {
    "on": {
    @@ -31,7 +38,10 @@
    },
    "点播中": {
    "on": {
    "广告": "广告中",
    "广告": {
    "target": "广告中",
    "cond": adValid
    },
    "直播": "直播中"
    }
    }
  11. xiaojundebug revised this gist Apr 11, 2022. No changes.
  12. xiaojundebug revised this gist Apr 11, 2022. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions machine.js
    Original file line number Diff line number Diff line change
    @@ -31,6 +31,7 @@
    },
    "点播中": {
    "on": {
    "广告": "广告中",
    "直播": "直播中"
    }
    }
  13. xiaojundebug revised this gist Apr 11, 2022. No changes.
  14. xiaojundebug revised this gist Apr 11, 2022. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion machine.js
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,8 @@
    "states": {
    "空闲": {
    "on": {
    "广告": "广告中"
    "广告": "广告中",
    "直播": "直播中",
    }
    },
    "广告中": {
  15. xiaojundebug created this gist Apr 11, 2022.
    38 changes: 38 additions & 0 deletions machine.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@

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

    const fetchMachine = Machine({
    "initial": "空闲",
    "states": {
    "空闲": {
    "on": {
    "广告": "广告中"
    }
    },
    "广告中": {
    "on": {
    "跳过": "直播中",
    }
    },
    "直播中": {
    "on": {
    "点播": "点播中"
    }
    },
    "点播中": {
    "on": {
    "直播": "直播中"
    }
    }
    }
    });