rxjs
Version:
Reactive Extensions for modern JavaScript
21 lines • 802 B
JavaScript
import { operate } from '../util/lift';
import { noop } from '../util/noop';
import { OperatorSubscriber } from './OperatorSubscriber';
export function buffer(closingNotifier) {
return operate(function (source, subscriber) {
var currentBuffer = [];
source.subscribe(new OperatorSubscriber(subscriber, function (value) { return currentBuffer.push(value); }, function () {
subscriber.next(currentBuffer);
subscriber.complete();
}));
closingNotifier.subscribe(new OperatorSubscriber(subscriber, function () {
var b = currentBuffer;
currentBuffer = [];
subscriber.next(b);
}, noop));
return function () {
currentBuffer = null;
};
});
}
//# sourceMappingURL=buffer.js.map