Implement delayed queue with RxJs Observable

前端 未结 1 671
[愿得一人]
[愿得一人] 2021-01-13 19:15

Imagine we have a queue of booleans (we don\'t need a complex datastructure since we wanna store only the fact of the order). Items can get into the queue at anytime in

相关标签:
1条回答
  • 2021-01-13 20:16

    You can use concatMap:

    delay = 1000; // delay in ms
    queue.concatMap(e =>
        Rx.Observable.of(e) // emit first item right away
          .concat(Rx.Observable.empty().delay(delay)) // delay next item
      )
    
    0 讨论(0)
提交回复
热议问题