Pause RxJS stream based on a value in the stream

前端 未结 6 481
一生所求
一生所求 2021-01-03 23:56

I have a simple component with a single button that starts and pauses a stream of numbers generated by RxJS timer.

import { Component, OnInit } from \'@angul         


        
6条回答
  •  臣服心动
    2021-01-04 00:24

    Your example is actually remarkably close to the working solution, no need for new custom operators.

    See the section on "Buffering" here:

    https://medium.com/@kddsky/pauseable-observables-in-rxjs-58ce2b8c7dfd

    And the working example here:

    https://thinkrx.io/gist/cef1572743cbf3f46105ec2ba56228cd

    It uses the same approach you already have, with bufferToggle and windowToggle, it looks like the main difference is you need to share your pause/active subject-

提交回复
热议问题