Actualizacion maquina principal
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / rxjs / _esm5 / internal / operators / bufferWhen.js
1 /** PURE_IMPORTS_START tslib,_Subscription,_OuterSubscriber,_util_subscribeToResult PURE_IMPORTS_END */
2 import * as tslib_1 from "tslib";
3 import { Subscription } from '../Subscription';
4 import { OuterSubscriber } from '../OuterSubscriber';
5 import { subscribeToResult } from '../util/subscribeToResult';
6 export function bufferWhen(closingSelector) {
7     return function (source) {
8         return source.lift(new BufferWhenOperator(closingSelector));
9     };
10 }
11 var BufferWhenOperator = /*@__PURE__*/ (function () {
12     function BufferWhenOperator(closingSelector) {
13         this.closingSelector = closingSelector;
14     }
15     BufferWhenOperator.prototype.call = function (subscriber, source) {
16         return source.subscribe(new BufferWhenSubscriber(subscriber, this.closingSelector));
17     };
18     return BufferWhenOperator;
19 }());
20 var BufferWhenSubscriber = /*@__PURE__*/ (function (_super) {
21     tslib_1.__extends(BufferWhenSubscriber, _super);
22     function BufferWhenSubscriber(destination, closingSelector) {
23         var _this = _super.call(this, destination) || this;
24         _this.closingSelector = closingSelector;
25         _this.subscribing = false;
26         _this.openBuffer();
27         return _this;
28     }
29     BufferWhenSubscriber.prototype._next = function (value) {
30         this.buffer.push(value);
31     };
32     BufferWhenSubscriber.prototype._complete = function () {
33         var buffer = this.buffer;
34         if (buffer) {
35             this.destination.next(buffer);
36         }
37         _super.prototype._complete.call(this);
38     };
39     BufferWhenSubscriber.prototype._unsubscribe = function () {
40         this.buffer = null;
41         this.subscribing = false;
42     };
43     BufferWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
44         this.openBuffer();
45     };
46     BufferWhenSubscriber.prototype.notifyComplete = function () {
47         if (this.subscribing) {
48             this.complete();
49         }
50         else {
51             this.openBuffer();
52         }
53     };
54     BufferWhenSubscriber.prototype.openBuffer = function () {
55         var closingSubscription = this.closingSubscription;
56         if (closingSubscription) {
57             this.remove(closingSubscription);
58             closingSubscription.unsubscribe();
59         }
60         var buffer = this.buffer;
61         if (this.buffer) {
62             this.destination.next(buffer);
63         }
64         this.buffer = [];
65         var closingNotifier;
66         try {
67             var closingSelector = this.closingSelector;
68             closingNotifier = closingSelector();
69         }
70         catch (err) {
71             return this.error(err);
72         }
73         closingSubscription = new Subscription();
74         this.closingSubscription = closingSubscription;
75         this.add(closingSubscription);
76         this.subscribing = true;
77         closingSubscription.add(subscribeToResult(this, closingNotifier));
78         this.subscribing = false;
79     };
80     return BufferWhenSubscriber;
81 }(OuterSubscriber));
82 //# sourceMappingURL=bufferWhen.js.map