Code coverage report for cjs/operator/retry.js

Statements: 98.55% (68 / 69)      Branches: 78.95% (15 / 19)      Functions: 100% (17 / 17)      Lines: 100% (63 / 63)      Ignored: none     

All files » cjs/operator/ » retry.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 841 4 2 2   1 1 25 25   1 1 1 25 25   1 33   1   1 1 1 33 33 33 33 33 33   1 73   1 29 29 29     1 2 2   1 105 105 105 105 105 105 105   1   1 1 1 105 105 105 105 105   1 84   1 99 99 99 99 23     76     1 2   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');
function retry(count) {
    if (count === void 0) { count = 0; }
    return this.lift(new RetryOperator(count, this));
}
exports.retry = retry;
var RetryOperator = (function () {
    function RetryOperator(count, source) {
        this.count = count;
        this.source = source;
    }
    RetryOperator.prototype.call = function (subscriber) {
        return new FirstRetrySubscriber(subscriber, this.count, this.source);
    };
    return RetryOperator;
})();
var FirstRetrySubscriber = (function (_super) {
    __extends(FirstRetrySubscriber, _super);
    function FirstRetrySubscriber(destination, count, source) {
        _super.call(this);
        this.destination = destination;
        this.count = count;
        this.source = source;
        destination.add(this);
        this.lastSubscription = this;
    }
    FirstRetrySubscriber.prototype._next = function (value) {
        this.destination.next(value);
    };
    FirstRetrySubscriber.prototype.error = function (error) {
        Eif (!this.isUnsubscribed) {
            this.unsubscribe();
            this.resubscribe();
        }
    };
    FirstRetrySubscriber.prototype._complete = function () {
        this.unsubscribe();
        this.destination.complete();
    };
    FirstRetrySubscriber.prototype.resubscribe = function (retried) {
        if (retried === void 0) { retried = 0; }
        var _a = this, lastSubscription = _a.lastSubscription, destination = _a.destination;
        destination.remove(lastSubscription);
        lastSubscription.unsubscribe();
        var nextSubscriber = new RetryMoreSubscriber(this, this.count, retried + 1);
        this.lastSubscription = this.source.subscribe(nextSubscriber);
        destination.add(this.lastSubscription);
    };
    return FirstRetrySubscriber;
})(Subscriber_1.Subscriber);
var RetryMoreSubscriber = (function (_super) {
    __extends(RetryMoreSubscriber, _super);
    function RetryMoreSubscriber(parent, count, retried) {
        Iif (retried === void 0) { retried = 0; }
        _super.call(this, null);
        this.parent = parent;
        this.count = count;
        this.retried = retried;
    }
    RetryMoreSubscriber.prototype._next = function (value) {
        this.parent.destination.next(value);
    };
    RetryMoreSubscriber.prototype._error = function (err) {
        var parent = this.parent;
        var retried = this.retried;
        var count = this.count;
        if (count && retried === count) {
            parent.destination.error(err);
        }
        else {
            parent.resubscribe(retried);
        }
    };
    RetryMoreSubscriber.prototype._complete = function () {
        this.parent.destination.complete();
    };
    return RetryMoreSubscriber;
})(Subscriber_1.Subscriber);
//# sourceMappingURL=retry.js.map