source: trip-planner-front/node_modules/rxjs/_esm5/internal/operators/retryWhen.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/** PURE_IMPORTS_START tslib,_Subject,_innerSubscribe PURE_IMPORTS_END */
2import * as tslib_1 from "tslib";
3import { Subject } from '../Subject';
4import { SimpleOuterSubscriber, innerSubscribe, SimpleInnerSubscriber } from '../innerSubscribe';
5export function retryWhen(notifier) {
6 return function (source) { return source.lift(new RetryWhenOperator(notifier, source)); };
7}
8var RetryWhenOperator = /*@__PURE__*/ (function () {
9 function RetryWhenOperator(notifier, source) {
10 this.notifier = notifier;
11 this.source = source;
12 }
13 RetryWhenOperator.prototype.call = function (subscriber, source) {
14 return source.subscribe(new RetryWhenSubscriber(subscriber, this.notifier, this.source));
15 };
16 return RetryWhenOperator;
17}());
18var RetryWhenSubscriber = /*@__PURE__*/ (function (_super) {
19 tslib_1.__extends(RetryWhenSubscriber, _super);
20 function RetryWhenSubscriber(destination, notifier, source) {
21 var _this = _super.call(this, destination) || this;
22 _this.notifier = notifier;
23 _this.source = source;
24 return _this;
25 }
26 RetryWhenSubscriber.prototype.error = function (err) {
27 if (!this.isStopped) {
28 var errors = this.errors;
29 var retries = this.retries;
30 var retriesSubscription = this.retriesSubscription;
31 if (!retries) {
32 errors = new Subject();
33 try {
34 var notifier = this.notifier;
35 retries = notifier(errors);
36 }
37 catch (e) {
38 return _super.prototype.error.call(this, e);
39 }
40 retriesSubscription = innerSubscribe(retries, new SimpleInnerSubscriber(this));
41 }
42 else {
43 this.errors = undefined;
44 this.retriesSubscription = undefined;
45 }
46 this._unsubscribeAndRecycle();
47 this.errors = errors;
48 this.retries = retries;
49 this.retriesSubscription = retriesSubscription;
50 errors.next(err);
51 }
52 };
53 RetryWhenSubscriber.prototype._unsubscribe = function () {
54 var _a = this, errors = _a.errors, retriesSubscription = _a.retriesSubscription;
55 if (errors) {
56 errors.unsubscribe();
57 this.errors = undefined;
58 }
59 if (retriesSubscription) {
60 retriesSubscription.unsubscribe();
61 this.retriesSubscription = undefined;
62 }
63 this.retries = undefined;
64 };
65 RetryWhenSubscriber.prototype.notifyNext = function () {
66 var _unsubscribe = this._unsubscribe;
67 this._unsubscribe = null;
68 this._unsubscribeAndRecycle();
69 this._unsubscribe = _unsubscribe;
70 this.source.subscribe(this);
71 };
72 return RetryWhenSubscriber;
73}(SimpleOuterSubscriber));
74//# sourceMappingURL=retryWhen.js.map
Note: See TracBrowser for help on using the repository browser.