wishthis/node_modules/rxjs/dist/esm5/internal/operators/buffer.js

22 lines
876 B
JavaScript
Raw Normal View History

2022-06-08 10:36:39 +00:00
import { operate } from '../util/lift';
import { noop } from '../util/noop';
import { createOperatorSubscriber } from './OperatorSubscriber';
2023-02-08 12:35:10 +00:00
import { innerFrom } from '../observable/innerFrom';
2022-06-08 10:36:39 +00:00
export function buffer(closingNotifier) {
return operate(function (source, subscriber) {
var currentBuffer = [];
source.subscribe(createOperatorSubscriber(subscriber, function (value) { return currentBuffer.push(value); }, function () {
subscriber.next(currentBuffer);
subscriber.complete();
}));
2023-02-08 12:35:10 +00:00
innerFrom(closingNotifier).subscribe(createOperatorSubscriber(subscriber, function () {
2022-06-08 10:36:39 +00:00
var b = currentBuffer;
currentBuffer = [];
subscriber.next(b);
}, noop));
return function () {
currentBuffer = null;
};
});
}
//# sourceMappingURL=buffer.js.map