buffer.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /** PURE_IMPORTS_START tslib,_innerSubscribe PURE_IMPORTS_END */
  2. import * as tslib_1 from "tslib";
  3. import { SimpleOuterSubscriber, innerSubscribe, SimpleInnerSubscriber } from '../innerSubscribe';
  4. export function buffer(closingNotifier) {
  5. return function bufferOperatorFunction(source) {
  6. return source.lift(new BufferOperator(closingNotifier));
  7. };
  8. }
  9. var BufferOperator = /*@__PURE__*/ (function () {
  10. function BufferOperator(closingNotifier) {
  11. this.closingNotifier = closingNotifier;
  12. }
  13. BufferOperator.prototype.call = function (subscriber, source) {
  14. return source.subscribe(new BufferSubscriber(subscriber, this.closingNotifier));
  15. };
  16. return BufferOperator;
  17. }());
  18. var BufferSubscriber = /*@__PURE__*/ (function (_super) {
  19. tslib_1.__extends(BufferSubscriber, _super);
  20. function BufferSubscriber(destination, closingNotifier) {
  21. var _this = _super.call(this, destination) || this;
  22. _this.buffer = [];
  23. _this.add(innerSubscribe(closingNotifier, new SimpleInnerSubscriber(_this)));
  24. return _this;
  25. }
  26. BufferSubscriber.prototype._next = function (value) {
  27. this.buffer.push(value);
  28. };
  29. BufferSubscriber.prototype.notifyNext = function () {
  30. var buffer = this.buffer;
  31. this.buffer = [];
  32. this.destination.next(buffer);
  33. };
  34. return BufferSubscriber;
  35. }(SimpleOuterSubscriber));
  36. //# sourceMappingURL=buffer.js.map