Using Rxjs, I'm looking for a way to create an observable that
N
eventsinterval
.After a certain time interval, it emits what has been accumulated till then.
I looked into bufferCount
and bufferTime
. However, I am unable to understand how to combine both behaviors such that it guarantees at least one to be fulfilled. so that all events are processed.
The bufferTime
operator allows you to specify an optional max buffer size. So you can do something like this:
bufferTime(2000, null, 5) // <-- buffer emits @ 2000ms OR when 5 items collected