UNPKG

rxjs

Version:

Reactive Extensions for modern JavaScript

21 lines 762 B
import { operate } from '../util/lift'; import { noop } from '../util/noop'; import { OperatorSubscriber } from './OperatorSubscriber'; export function buffer(closingNotifier) { return operate((source, subscriber) => { let currentBuffer = []; source.subscribe(new OperatorSubscriber(subscriber, (value) => currentBuffer.push(value), () => { subscriber.next(currentBuffer); subscriber.complete(); })); closingNotifier.subscribe(new OperatorSubscriber(subscriber, () => { const b = currentBuffer; currentBuffer = []; subscriber.next(b); }, noop)); return () => { currentBuffer = null; }; }); } //# sourceMappingURL=buffer.js.map