Code coverage report for cjs/operator/retryWhen.js

Statements: 100% (97 / 97)      Branches: 76.47% (13 / 17)      Functions: 100% (26 / 26)      Lines: 100% (94 / 94)      Ignored: none     

All files » cjs/operator/ » retryWhen.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 1291 6 3 3   1 1 1 1 1 20   1 1 1 20 20   1 20   1   1 1 1 20 20 20 20 20 20   1 33   1 13 13 13 13 13 13 13 1     12 12 12 12     13     1 3 3   1 4   1 9 9   1 41 41 37     4     1 16 16 16 16 11     1 12 12 12 12 12 12   1   1 1 1 12 12   1 21   1 9   1 1   1   1 1 1 12 12   1 12   1 3   1 4   1    
var __extends = (this && this.__extends) || function (d, b) {
    for (var p in b) Eif (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Subscriber_1 = require('../Subscriber');
var Subject_1 = require('../Subject');
var tryCatch_1 = require('../util/tryCatch');
var errorObject_1 = require('../util/errorObject');
function retryWhen(notifier) {
    return this.lift(new RetryWhenOperator(notifier, this));
}
exports.retryWhen = retryWhen;
var RetryWhenOperator = (function () {
    function RetryWhenOperator(notifier, source) {
        this.notifier = notifier;
        this.source = source;
    }
    RetryWhenOperator.prototype.call = function (subscriber) {
        return new FirstRetryWhenSubscriber(subscriber, this.notifier, this.source);
    };
    return RetryWhenOperator;
})();
var FirstRetryWhenSubscriber = (function (_super) {
    __extends(FirstRetryWhenSubscriber, _super);
    function FirstRetryWhenSubscriber(destination, notifier, source) {
        _super.call(this);
        this.destination = destination;
        this.notifier = notifier;
        this.source = source;
        destination.add(this);
        this.lastSubscription = this;
    }
    FirstRetryWhenSubscriber.prototype._next = function (value) {
        this.destination.next(value);
    };
    FirstRetryWhenSubscriber.prototype.error = function (err) {
        var destination = this.destination;
        Eif (!this.isUnsubscribed) {
            _super.prototype.unsubscribe.call(this);
            Eif (!this.retryNotifications) {
                this.errors = new Subject_1.Subject();
                var notifications = tryCatch_1.tryCatch(this.notifier).call(this, this.errors);
                if (notifications === errorObject_1.errorObject) {
                    destination.error(errorObject_1.errorObject.e);
                }
                else {
                    this.retryNotifications = notifications;
                    var notificationSubscriber = new RetryNotificationSubscriber(this);
                    this.notificationSubscription = notifications.subscribe(notificationSubscriber);
                    destination.add(this.notificationSubscription);
                }
            }
            this.errors.next(err);
        }
    };
    FirstRetryWhenSubscriber.prototype.destinationError = function (err) {
        this.tearDown();
        this.destination.error(err);
    };
    FirstRetryWhenSubscriber.prototype._complete = function () {
        this.destinationComplete();
    };
    FirstRetryWhenSubscriber.prototype.destinationComplete = function () {
        this.tearDown();
        this.destination.complete();
    };
    FirstRetryWhenSubscriber.prototype.unsubscribe = function () {
        var lastSubscription = this.lastSubscription;
        if (lastSubscription === this) {
            _super.prototype.unsubscribe.call(this);
        }
        else {
            this.tearDown();
        }
    };
    FirstRetryWhenSubscriber.prototype.tearDown = function () {
        _super.prototype.unsubscribe.call(this);
        this.lastSubscription.unsubscribe();
        var notificationSubscription = this.notificationSubscription;
        if (notificationSubscription) {
            notificationSubscription.unsubscribe();
        }
    };
    FirstRetryWhenSubscriber.prototype.resubscribe = function () {
        var _a = this, destination = _a.destination, lastSubscription = _a.lastSubscription;
        destination.remove(lastSubscription);
        lastSubscription.unsubscribe();
        var nextSubscriber = new MoreRetryWhenSubscriber(this);
        this.lastSubscription = this.source.subscribe(nextSubscriber);
        destination.add(this.lastSubscription);
    };
    return FirstRetryWhenSubscriber;
})(Subscriber_1.Subscriber);
var MoreRetryWhenSubscriber = (function (_super) {
    __extends(MoreRetryWhenSubscriber, _super);
    function MoreRetryWhenSubscriber(parent) {
        _super.call(this, null);
        this.parent = parent;
    }
    MoreRetryWhenSubscriber.prototype._next = function (value) {
        this.parent.destination.next(value);
    };
    MoreRetryWhenSubscriber.prototype._error = function (err) {
        this.parent.errors.next(err);
    };
    MoreRetryWhenSubscriber.prototype._complete = function () {
        this.parent.destinationComplete();
    };
    return MoreRetryWhenSubscriber;
})(Subscriber_1.Subscriber);
var RetryNotificationSubscriber = (function (_super) {
    __extends(RetryNotificationSubscriber, _super);
    function RetryNotificationSubscriber(parent) {
        _super.call(this, null);
        this.parent = parent;
    }
    RetryNotificationSubscriber.prototype._next = function (value) {
        this.parent.resubscribe();
    };
    RetryNotificationSubscriber.prototype._error = function (err) {
        this.parent.destinationError(err);
    };
    RetryNotificationSubscriber.prototype._complete = function () {
        this.parent.destinationComplete();
    };
    return RetryNotificationSubscriber;
})(Subscriber_1.Subscriber);
//# sourceMappingURL=retryWhen.js.map