Code coverage report for cjs/operators/retryWhen.js

Statements: 96.15% (100 / 104)      Branches: 65.38% (17 / 26)      Functions: 96.3% (26 / 27)      Lines: 97.92% (94 / 96)      Ignored: none     

All files » cjs/operators/ » 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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174    1 1   3   3   53   1   1   1   1   1   1   1   1 17     1 1 17   17 17     1 17     1     1 1   1 17   17 17 17 17 17     1 26     1 10 10 10 10 10 10     10 10 10     10       1 3 3     1 4     1 8 8     1 28 28 24   4       1 15 15 15 15 10       1 9 9 9     1     1 1   1 9   9 9     1 17     1 8     1       1     1 1   1 10   10 10         1 9     1 3     1 4     1     1  
'use strict';
 
exports.__esModule = true;
exports['default'] = retryWhen;
 
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
 
function _inherits(subClass, superClass) { Iif (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); Eif (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
 
function _classCallCheck(instance, Constructor) { Iif (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
 
var _Subscriber4 = require('../Subscriber');
 
var _Subscriber5 = _interopRequireDefault(_Subscriber4);
 
var _Subject = require('../Subject');
 
var _Subject2 = _interopRequireDefault(_Subject);
 
var _utilTryCatch = require('../util/tryCatch');
 
var _utilTryCatch2 = _interopRequireDefault(_utilTryCatch);
 
var _utilErrorObject = require('../util/errorObject');
 
function retryWhen(notifier) {
    return this.lift(new RetryWhenOperator(notifier, this));
}
 
var RetryWhenOperator = (function () {
    function RetryWhenOperator(notifier, source) {
        _classCallCheck(this, RetryWhenOperator);
 
        this.notifier = notifier;
        this.source = source;
    }
 
    RetryWhenOperator.prototype.call = function call(subscriber) {
        return new FirstRetryWhenSubscriber(subscriber, this.notifier, this.source);
    };
 
    return RetryWhenOperator;
})();
 
var FirstRetryWhenSubscriber = (function (_Subscriber) {
    _inherits(FirstRetryWhenSubscriber, _Subscriber);
 
    function FirstRetryWhenSubscriber(destination, notifier, source) {
        _classCallCheck(this, FirstRetryWhenSubscriber);
 
        _Subscriber.call(this, null);
        this.destination = destination;
        this.notifier = notifier;
        this.source = source;
        this.lastSubscription = this;
    }
 
    FirstRetryWhenSubscriber.prototype._next = function _next(value) {
        this.destination.next(value);
    };
 
    FirstRetryWhenSubscriber.prototype.error = function error(err) {
        Eif (!this.isUnsubscribed) {
            _Subscriber.prototype.unsubscribe.call(this);
            Eif (!this.retryNotifications) {
                this.errors = new _Subject2['default']();
                var notifications = _utilTryCatch2['default'](this.notifier).call(this, this.errors);
                Iif (notifications === _utilErrorObject.errorObject) {
                    this.destination.error(_utilErrorObject.errorObject.e);
                } else {
                    this.retryNotifications = notifications;
                    var notificationSubscriber = new RetryNotificationSubscriber(this);
                    this.notificationSubscription = notifications.subscribe(notificationSubscriber);
                }
            }
            this.errors.next(err);
        }
    };
 
    FirstRetryWhenSubscriber.prototype.destinationError = function destinationError(err) {
        this.tearDown();
        this.destination.error(err);
    };
 
    FirstRetryWhenSubscriber.prototype._complete = function _complete() {
        this.destinationComplete();
    };
 
    FirstRetryWhenSubscriber.prototype.destinationComplete = function destinationComplete() {
        this.tearDown();
        this.destination.complete();
    };
 
    FirstRetryWhenSubscriber.prototype.unsubscribe = function unsubscribe() {
        var lastSubscription = this.lastSubscription;
        if (lastSubscription === this) {
            _Subscriber.prototype.unsubscribe.call(this);
        } else {
            this.tearDown();
        }
    };
 
    FirstRetryWhenSubscriber.prototype.tearDown = function tearDown() {
        _Subscriber.prototype.unsubscribe.call(this);
        this.lastSubscription.unsubscribe();
        var notificationSubscription = this.notificationSubscription;
        if (notificationSubscription) {
            notificationSubscription.unsubscribe();
        }
    };
 
    FirstRetryWhenSubscriber.prototype.resubscribe = function resubscribe() {
        this.lastSubscription.unsubscribe();
        var nextSubscriber = new MoreRetryWhenSubscriber(this);
        this.lastSubscription = this.source.subscribe(nextSubscriber);
    };
 
    return FirstRetryWhenSubscriber;
})(_Subscriber5['default']);
 
var MoreRetryWhenSubscriber = (function (_Subscriber2) {
    _inherits(MoreRetryWhenSubscriber, _Subscriber2);
 
    function MoreRetryWhenSubscriber(parent) {
        _classCallCheck(this, MoreRetryWhenSubscriber);
 
        _Subscriber2.call(this, null);
        this.parent = parent;
    }
 
    MoreRetryWhenSubscriber.prototype._next = function _next(value) {
        this.parent.destination.next(value);
    };
 
    MoreRetryWhenSubscriber.prototype._error = function _error(err) {
        this.parent.errors.next(err);
    };
 
    MoreRetryWhenSubscriber.prototype._complete = function _complete() {
        this.parent.destinationComplete();
    };
 
    return MoreRetryWhenSubscriber;
})(_Subscriber5['default']);
 
var RetryNotificationSubscriber = (function (_Subscriber3) {
    _inherits(RetryNotificationSubscriber, _Subscriber3);
 
    function RetryNotificationSubscriber(parent) {
        _classCallCheck(this, RetryNotificationSubscriber);
 
        _Subscriber3.call(this, null);
        this.parent = parent;
    }
 
    //# sourceMappingURL=retryWhen.js.map
 
    RetryNotificationSubscriber.prototype._next = function _next(value) {
        this.parent.resubscribe();
    };
 
    RetryNotificationSubscriber.prototype._error = function _error(err) {
        this.parent.destinationError(err);
    };
 
    RetryNotificationSubscriber.prototype._complete = function _complete() {
        this.parent.destinationComplete();
    };
 
    return RetryNotificationSubscriber;
})(_Subscriber5['default']);
 
module.exports = exports['default'];
//# sourceMappingURL=retryWhen.js.map