Code coverage report for RxJS/dist/cjs/Subscriber.js

Statements: 94.95% (94 / 99)      Branches: 83.05% (49 / 59)      Functions: 100% (20 / 20)      Lines: 98.7% (76 / 77)      Ignored: none     

All files » RxJS/dist/cjs/ » Subscriber.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    1   1   4   6448   1   1   1   1   1   1   1   1   1   1 1   1 6448   6448 6448 6448 6448 5361   1087 1087 80 1007 974       1 1071 1071 1071 1071 1071     1 174     1 124     1 194     1   6708 6708 1559   5149       1   734 367   367       1 3290 598 2692 856   1836       1 9216 9198       1 634 622 619       1 4971 4916 1566       1     28200 28200   4152   24048       8284 8284       8284         1     1 1
'use strict';
 
exports.__esModule = true;
 
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; Iif ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { Eif (protoProps) defineProperties(Constructor.prototype, protoProps); Iif (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
 
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
 
function _classCallCheck(instance, Constructor) { Iif (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
 
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; }
 
var _utilNoop = require('./util/noop');
 
var _utilNoop2 = _interopRequireDefault(_utilNoop);
 
var _utilThrowError = require('./util/throwError');
 
var _utilThrowError2 = _interopRequireDefault(_utilThrowError);
 
var _utilTryOrOnError = require('./util/tryOrOnError');
 
var _utilTryOrOnError2 = _interopRequireDefault(_utilTryOrOnError);
 
var _Subscription2 = require('./Subscription');
 
var _Subscription3 = _interopRequireDefault(_Subscription2);
 
var Subscriber = (function (_Subscription) {
    _inherits(Subscriber, _Subscription);
 
    function Subscriber(destination) {
        _classCallCheck(this, Subscriber);
 
        _Subscription.call(this);
        this._isUnsubscribed = false;
        this.destination = destination;
        if (!destination) {
            return;
        }
        var subscription = destination._subscription;
        if (subscription) {
            this._subscription = subscription;
        } else if (destination instanceof Subscriber) {
            this._subscription = destination;
        }
    }
 
    Subscriber.create = function create(next, error, complete) {
        var subscriber = new Subscriber();
        subscriber._next = typeof next === "function" && _utilTryOrOnError2['default'](next) || _utilNoop2['default'];
        subscriber._error = typeof error === "function" && error || _utilThrowError2['default'];
        subscriber._complete = typeof complete === "function" && complete || _utilNoop2['default'];
        return subscriber;
    };
 
    Subscriber.prototype._next = function _next(value) {
        this.destination.next(value);
    };
 
    Subscriber.prototype._error = function _error(err) {
        this.destination.error(err);
    };
 
    Subscriber.prototype._complete = function _complete() {
        this.destination.complete();
    };
 
    Subscriber.prototype.add = function add(sub) {
        // route add to the shared Subscription if it exists
        var _subscription = this._subscription;
        if (_subscription) {
            _subscription.add(sub);
        } else {
            _Subscription.prototype.add.call(this, sub);
        }
    };
 
    Subscriber.prototype.remove = function remove(sub) {
        // route remove to the shared Subscription if it exists
        if (this._subscription) {
            this._subscription.remove(sub);
        } else {
            _Subscription.prototype.remove.call(this, sub);
        }
    };
 
    Subscriber.prototype.unsubscribe = function unsubscribe() {
        if (this._isUnsubscribed) {
            return;
        } else if (this._subscription) {
            this._isUnsubscribed = true;
        } else {
            _Subscription.prototype.unsubscribe.call(this);
        }
    };
 
    Subscriber.prototype.next = function next(value) {
        if (!this.isUnsubscribed) {
            this._next(value);
        }
    };
 
    Subscriber.prototype.error = function error(_error2) {
        if (!this.isUnsubscribed) {
            this._error(_error2);
            this.unsubscribe();
        }
    };
 
    Subscriber.prototype.complete = function complete() {
        if (!this.isUnsubscribed) {
            this._complete();
            this.unsubscribe();
        }
    };
 
    _createClass(Subscriber, [{
        key: 'isUnsubscribed',
        get: function get() {
            var subscription = this._subscription;
            if (subscription) {
                // route to the shared Subscription if it exists
                return this._isUnsubscribed || subscription.isUnsubscribed;
            } else {
                return this._isUnsubscribed;
            }
        },
        set: function set(value) {
            var subscription = this._subscription;
            Iif (subscription) {
                // route to the shared Subscription if it exists
                subscription.isUnsubscribed = Boolean(value);
            } else {
                this._isUnsubscribed = Boolean(value);
            }
        }
    }]);
 
    return Subscriber;
})(_Subscription3['default']);
 
exports['default'] = Subscriber;
module.exports = exports['default'];