Code coverage report for cjs/operator/catch.js

Statements: 100% (45 / 45)      Branches: 77.78% (7 / 9)      Functions: 100% (12 / 12)      Lines: 100% (42 / 42)      Ignored: none     

All files » cjs/operator/ » catch.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 651 2 1 1   1 1 1                 1 13 13 13 13   1 1 1 13   1 16   1   1 1 1 16 16 16 16 16 16   1 30   1 12 12 1     11 11     1 2 2   1 16   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 tryCatch_1 = require('../util/tryCatch');
var errorObject_1 = require('../util/errorObject');
/**
 * Catches errors on the observable to be handled by returning a new observable or throwing an error.
 * @param {function} selector a function that takes as arguments `err`, which is the error, and `caught`, which
 *  is the source observable, in case you'd like to "retry" that observable by returning it again. Whatever observable
 *  is returned by the `selector` will be used to continue the observable chain.
 * @return {Observable} an observable that originates from either the source or the observable returned by the
 *  catch `selector` function.
 */
function _catch(selector) {
    var catchOperator = new CatchOperator(selector);
    var caught = this.lift(catchOperator);
    catchOperator.caught = caught;
    return caught;
}
exports._catch = _catch;
var CatchOperator = (function () {
    function CatchOperator(selector) {
        this.selector = selector;
    }
    CatchOperator.prototype.call = function (subscriber) {
        return new CatchSubscriber(subscriber, this.selector, this.caught);
    };
    return CatchOperator;
})();
var CatchSubscriber = (function (_super) {
    __extends(CatchSubscriber, _super);
    function CatchSubscriber(destination, selector, caught) {
        _super.call(this, null);
        this.destination = destination;
        this.selector = selector;
        this.caught = caught;
        this.lastSubscription = this;
        this.destination.add(this);
    }
    CatchSubscriber.prototype._next = function (value) {
        this.destination.next(value);
    };
    CatchSubscriber.prototype._error = function (err) {
        var result = tryCatch_1.tryCatch(this.selector)(err, this.caught);
        if (result === errorObject_1.errorObject) {
            this.destination.error(errorObject_1.errorObject.e);
        }
        else {
            this.lastSubscription.unsubscribe();
            this.lastSubscription = result.subscribe(this.destination);
        }
    };
    CatchSubscriber.prototype._complete = function () {
        this.lastSubscription.unsubscribe();
        this.destination.complete();
    };
    CatchSubscriber.prototype._unsubscribe = function () {
        this.lastSubscription.unsubscribe();
    };
    return CatchSubscriber;
})(Subscriber_1.Subscriber);
//# sourceMappingURL=catch.js.map