0
votes

with RXJs I am trying to achieve something like this:

  1. clickStream.bufferWithTime(500).subscribe(f)
  2. clickStream.throttle(500).subscribe(f)

Version 1 calls f every 500ms no matter if there was a clickEvent or not. Version 2 calls f only if clickStream did send a clickEvent and then stopped for at least 500ms.

I would like to to call f every 500ms as long as clickStream is emitting events. As soon as it does stop to emit, f should called be one last time. If clickStream restarts to emit the same should happen again.

1

1 Answers

3
votes
clickStream.bufferWithTime(500).filter(arr => arr.length > 0).subscribe(f)