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

22 lines
836 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((source, subscriber) => {
let currentBuffer = [];
source.subscribe(createOperatorSubscriber(subscriber, (value) => currentBuffer.push(value), () => {
subscriber.next(currentBuffer);
subscriber.complete();
}));
2023-02-08 12:35:10 +00:00
innerFrom(closingNotifier).subscribe(createOperatorSubscriber(subscriber, () => {
2022-06-08 10:36:39 +00:00
const b = currentBuffer;
currentBuffer = [];
subscriber.next(b);
}, noop));
return () => {
currentBuffer = null;
};
});
}
//# sourceMappingURL=buffer.js.map