Code coverage report for cjs/observables/ConnectableObservable.js

Statements: 96.39% (80 / 83)      Branches: 68.75% (22 / 32)      Functions: 100% (18 / 18)      Lines: 98.67% (74 / 75)      Ignored: none     

All files » cjs/observables/ » ConnectableObservable.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    1   2   96   4   1   1   1   1   1 1   1 29   29 29 29     1 42     1 72 72 41   31     1 30 30 30     30 30 30     1 15     1     1   1 1   1 30   30 30     1 23 23 23 23     1     1 1   1 15   15   15 15 15     1 22 22 22 15   22 22     1     1 1   1 22   22 22         1 14 14 10 10       1     1  
'use strict';
 
exports.__esModule = true;
 
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 _Observable3 = require('../Observable');
 
var _Observable4 = _interopRequireDefault(_Observable3);
 
var _Subscription3 = require('../Subscription');
 
var _Subscription4 = _interopRequireDefault(_Subscription3);
 
var ConnectableObservable = (function (_Observable) {
    _inherits(ConnectableObservable, _Observable);
 
    function ConnectableObservable(source, subjectFactory) {
        _classCallCheck(this, ConnectableObservable);
 
        _Observable.call(this);
        this.source = source;
        this.subjectFactory = subjectFactory;
    }
 
    ConnectableObservable.prototype._subscribe = function _subscribe(subscriber) {
        return this._getSubject().subscribe(subscriber);
    };
 
    ConnectableObservable.prototype._getSubject = function _getSubject() {
        var subject = this.subject;
        if (subject && !subject.isUnsubscribed) {
            return subject;
        }
        return this.subject = this.subjectFactory();
    };
 
    ConnectableObservable.prototype.connect = function connect() {
        var source = this.source;
        var subscription = this.subscription;
        Iif (subscription && !subscription.isUnsubscribed) {
            return subscription;
        }
        subscription = source.subscribe(this._getSubject());
        subscription.add(new ConnectableSubscription(this));
        return this.subscription = subscription;
    };
 
    ConnectableObservable.prototype.refCount = function refCount() {
        return new RefCountObservable(this);
    };
 
    return ConnectableObservable;
})(_Observable4['default']);
 
exports['default'] = ConnectableObservable;
 
var ConnectableSubscription = (function (_Subscription) {
    _inherits(ConnectableSubscription, _Subscription);
 
    function ConnectableSubscription(connectable) {
        _classCallCheck(this, ConnectableSubscription);
 
        _Subscription.call(this);
        this.connectable = connectable;
    }
 
    ConnectableSubscription.prototype._unsubscribe = function _unsubscribe() {
        var connectable = this.connectable;
        connectable.subject = void 0;
        connectable.subscription = void 0;
        this.connectable = void 0;
    };
 
    return ConnectableSubscription;
})(_Subscription4['default']);
 
var RefCountObservable = (function (_Observable2) {
    _inherits(RefCountObservable, _Observable2);
 
    function RefCountObservable(connectable) {
        var refCount = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1];
 
        _classCallCheck(this, RefCountObservable);
 
        _Observable2.call(this);
        this.connectable = connectable;
        this.refCount = refCount;
    }
 
    RefCountObservable.prototype._subscribe = function _subscribe(subscriber) {
        var connectable = this.connectable;
        var subscription = connectable.subscribe(subscriber);
        if (++this.refCount === 1) {
            this.connection = connectable.connect();
        }
        subscription.add(new RefCountSubscription(this));
        return subscription;
    };
 
    return RefCountObservable;
})(_Observable4['default']);
 
var RefCountSubscription = (function (_Subscription2) {
    _inherits(RefCountSubscription, _Subscription2);
 
    function RefCountSubscription(refCountObservable) {
        _classCallCheck(this, RefCountSubscription);
 
        _Subscription2.call(this);
        this.refCountObservable = refCountObservable;
    }
 
    //# sourceMappingURL=ConnectableObservable.js.map
 
    RefCountSubscription.prototype._unsubscribe = function _unsubscribe() {
        var observable = this.refCountObservable;
        if (--observable.refCount === 0) {
            observable.connection.unsubscribe();
            observable.connection = void 0;
        }
    };
 
    return RefCountSubscription;
})(_Subscription4['default']);
 
module.exports = exports['default'];
//# sourceMappingURL=ConnectableObservable.js.map