# Code coverage report for RxJS/dist/cjs/testing/ColdObservable.js

## Statements: 95.65% (44 / 46) Branches: 62.5% (10 / 16) Functions: 100% (9 / 9) Lines: 100% (38 / 38) Ignored: none

All files » RxJS/dist/cjs/testing/ » ColdObservable.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

    1

    4

    338

    1

    1

    1

    1

    1

    1

    1

    1

    1

    1
    1

    1
    338

    338
    242
    242
    242
    226

    242
    242

    338
    338
    338

    1
    242
    242
    713
    713
    541
    541
    541

    1

    1

    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 _Observable2 = require('../Observable');

    var _Observable3 = _interopRequireDefault(_Observable2);

    var _Subscription = require('../Subscription');

    var _Subscription2 = _interopRequireDefault(_Subscription);

    var _SubscriptionLoggable = require('./SubscriptionLoggable');

    var _SubscriptionLoggable2 = _interopRequireDefault(_SubscriptionLoggable);

    var _utilApplyMixins = require('../util/applyMixins');

    var _utilApplyMixins2 = _interopRequireDefault(_utilApplyMixins);

    var ColdObservable = (function (_Observable) {
        _inherits(ColdObservable, _Observable);

        function ColdObservable(messages, scheduler) {
            _classCallCheck(this, ColdObservable);

            _Observable.call(this, function (subscriber) {
                var observable = this;
                var index = observable.logSubscribedFrame();
                subscriber.add(new _Subscription2['default'](function () {
                    observable.logUnsubscribedFrame(index);
                }));
                observable.scheduleMessages(subscriber);
                return subscriber;
            });
            this.messages = messages;
            this.subscriptions = [];
            this.scheduler = scheduler;
        }

        ColdObservable.prototype.scheduleMessages = function scheduleMessages(subscriber) {
            var messagesLength = this.messages.length;
            for (var i = 0; i < messagesLength; i++) {
                var message = this.messages[i];
                subscriber.add(this.scheduler.schedule(function (_ref) {
                    var message = _ref.message;
                    var subscriber = _ref.subscriber;
                    message.notification.observe(subscriber);
                }, message.frame, { message: message, subscriber: subscriber }));
            }
        };

        return ColdObservable;
    })(_Observable3['default']);

    exports['default'] = ColdObservable;

    _utilApplyMixins2['default'](ColdObservable, [_SubscriptionLoggable2['default']]);
    module.exports = exports['default'];