-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bufferTime minBufferSize #2601
Comments
Running into the same issue. I have an event stream where I want to catch a timed buffer after the first emitted value rather than endless empty buffers being emitted. Edit: I was able to do this with this.source.bufferToggle(this.source.throttleTime(200), () => Observable.timer(200))
.subscribe(buffered => {
...
}); |
This just bit me in the butt. I had expected buffer to only emit when there actually was new values (Like normal observables), and not whenever the timer ticked. But a minBufferSize could definitely fix that. |
another simple fix would be to filter empty events:
But I agree that it should be supported by the library in a more efficient way |
Posting this answer since it can help other people (like me) that found this issue in their seek for the right operator. events$.pipe(buffer(events$.pipe(auditTime(DELAY))) (You may want to This will wait for events. You can replace |
Filtering empty events is simply 'hiding' the problem in the first place. I noticed CPU utilization of about 10% on a page with 4 controls using bufferTime(250), when it should have been near zero - it's clearly incorrect to continually spit out empty values, when the very documentation states 'Collects values from the past as an array, and emits those arrays periodically in time.' - if there's nothing to collect, then it shouldn't emit anything. |
How to set the rate limit along with this like using take operator |
Hello.
I think it can be also very helpful to have a minBufferSize parameter that will prevent the buffer from emitting if there are not enough source values to emit so that the pipeline will not need to check if there's actually something to process. Currently an empty array is emitted.
To emulate current behaviour the default is 0.
A value of X will mean "emit after delay only if buffer's has at least X elements, otherwise emit immediately after one is available".
What do you think?
The text was updated successfully, but these errors were encountered: