2 var __extends = (this && this.__extends) || (function () {
3 var extendStatics = function (d, b) {
4 extendStatics = Object.setPrototypeOf ||
5 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7 return extendStatics(d, b);
9 return function (d, b) {
11 function __() { this.constructor = d; }
12 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15 Object.defineProperty(exports, "__esModule", { value: true });
16 var Subject_1 = require("../Subject");
17 var innerSubscribe_1 = require("../innerSubscribe");
18 function retryWhen(notifier) {
19 return function (source) { return source.lift(new RetryWhenOperator(notifier, source)); };
21 exports.retryWhen = retryWhen;
22 var RetryWhenOperator = (function () {
23 function RetryWhenOperator(notifier, source) {
24 this.notifier = notifier;
27 RetryWhenOperator.prototype.call = function (subscriber, source) {
28 return source.subscribe(new RetryWhenSubscriber(subscriber, this.notifier, this.source));
30 return RetryWhenOperator;
32 var RetryWhenSubscriber = (function (_super) {
33 __extends(RetryWhenSubscriber, _super);
34 function RetryWhenSubscriber(destination, notifier, source) {
35 var _this = _super.call(this, destination) || this;
36 _this.notifier = notifier;
37 _this.source = source;
40 RetryWhenSubscriber.prototype.error = function (err) {
41 if (!this.isStopped) {
42 var errors = this.errors;
43 var retries = this.retries;
44 var retriesSubscription = this.retriesSubscription;
46 errors = new Subject_1.Subject();
48 var notifier = this.notifier;
49 retries = notifier(errors);
52 return _super.prototype.error.call(this, e);
54 retriesSubscription = innerSubscribe_1.innerSubscribe(retries, new innerSubscribe_1.SimpleInnerSubscriber(this));
57 this.errors = undefined;
58 this.retriesSubscription = undefined;
60 this._unsubscribeAndRecycle();
62 this.retries = retries;
63 this.retriesSubscription = retriesSubscription;
67 RetryWhenSubscriber.prototype._unsubscribe = function () {
68 var _a = this, errors = _a.errors, retriesSubscription = _a.retriesSubscription;
71 this.errors = undefined;
73 if (retriesSubscription) {
74 retriesSubscription.unsubscribe();
75 this.retriesSubscription = undefined;
77 this.retries = undefined;
79 RetryWhenSubscriber.prototype.notifyNext = function () {
80 var _unsubscribe = this._unsubscribe;
81 this._unsubscribe = null;
82 this._unsubscribeAndRecycle();
83 this._unsubscribe = _unsubscribe;
84 this.source.subscribe(this);
86 return RetryWhenSubscriber;
87 }(innerSubscribe_1.SimpleOuterSubscriber));
88 //# sourceMappingURL=retryWhen.js.map