4cf885325635e366390a1236b6c7874e1c3b24f9
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / rxjs / _esm5 / internal / operators / retryWhen.js
1 /** PURE_IMPORTS_START tslib,_Subject,_OuterSubscriber,_util_subscribeToResult PURE_IMPORTS_END */
2 import * as tslib_1 from "tslib";
3 import { Subject } from '../Subject';
4 import { OuterSubscriber } from '../OuterSubscriber';
5 import { subscribeToResult } from '../util/subscribeToResult';
6 export function retryWhen(notifier) {
7     return function (source) { return source.lift(new RetryWhenOperator(notifier, source)); };
8 }
9 var RetryWhenOperator = /*@__PURE__*/ (function () {
10     function RetryWhenOperator(notifier, source) {
11         this.notifier = notifier;
12         this.source = source;
13     }
14     RetryWhenOperator.prototype.call = function (subscriber, source) {
15         return source.subscribe(new RetryWhenSubscriber(subscriber, this.notifier, this.source));
16     };
17     return RetryWhenOperator;
18 }());
19 var RetryWhenSubscriber = /*@__PURE__*/ (function (_super) {
20     tslib_1.__extends(RetryWhenSubscriber, _super);
21     function RetryWhenSubscriber(destination, notifier, source) {
22         var _this = _super.call(this, destination) || this;
23         _this.notifier = notifier;
24         _this.source = source;
25         return _this;
26     }
27     RetryWhenSubscriber.prototype.error = function (err) {
28         if (!this.isStopped) {
29             var errors = this.errors;
30             var retries = this.retries;
31             var retriesSubscription = this.retriesSubscription;
32             if (!retries) {
33                 errors = new Subject();
34                 try {
35                     var notifier = this.notifier;
36                     retries = notifier(errors);
37                 }
38                 catch (e) {
39                     return _super.prototype.error.call(this, e);
40                 }
41                 retriesSubscription = subscribeToResult(this, retries);
42             }
43             else {
44                 this.errors = null;
45                 this.retriesSubscription = null;
46             }
47             this._unsubscribeAndRecycle();
48             this.errors = errors;
49             this.retries = retries;
50             this.retriesSubscription = retriesSubscription;
51             errors.next(err);
52         }
53     };
54     RetryWhenSubscriber.prototype._unsubscribe = function () {
55         var _a = this, errors = _a.errors, retriesSubscription = _a.retriesSubscription;
56         if (errors) {
57             errors.unsubscribe();
58             this.errors = null;
59         }
60         if (retriesSubscription) {
61             retriesSubscription.unsubscribe();
62             this.retriesSubscription = null;
63         }
64         this.retries = null;
65     };
66     RetryWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
67         var _unsubscribe = this._unsubscribe;
68         this._unsubscribe = null;
69         this._unsubscribeAndRecycle();
70         this._unsubscribe = _unsubscribe;
71         this.source.subscribe(this);
72     };
73     return RetryWhenSubscriber;
74 }(OuterSubscriber));
75 //# sourceMappingURL=retryWhen.js.map