-
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
RxJS 5 bufferWithTimeOrCount? (add maxCount to bufferTime) #1295
Comments
Hmmm... seems like an oversight. I think we can probably add an additional argument to Until we add that, you could use something like this: (I haven't tested it, and it looks a little gross but with some tweaks it may work): function bufferWithTimeOrCount(source, duration, bufferSize) {
let reset = false;
const buffers = source.scan((buffer, x) => {
if (reset) {
buffer = [];
reset = false;
}
buffer.push(x);
return buffer;
}, []).share();
const bufferCounted = buffers.filter(buffer => buffer.length < bufferSize);
const timer = Observable.of(null).merge(bufferCounted).switchMap(() => Observable.timer(duration));
return buffers.sample(timer.merge(bufferCounted)).do(() => reset = true);
} |
Thank you for your patience and for bring this issue up for us, @avielfedida. We'll get it fixed. |
Contributors or those looking to implement this:The idea I have here is that we can add an optional The operator function itself can be mildly polymorphic: |
Sorry if I have the details wrong, but It looks like in the current implementation of I have a small implementation for |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
So RxJS 5 currently not containing
bufferWithTimeOrCount
, is it planned to be added in the future?, anyway I was looking for comparable way to "do"bufferWithTimeOrCount
in RxJS 5, should I create my own operator or there is a nicer combo with the already ported operators?The text was updated successfully, but these errors were encountered: