# Code coverage report for RxJS/dist/cjs/observables/ForkJoinObservable.js

## Statements: 96.61% (57 / 59) Branches: 66.67% (12 / 18) Functions: 100% (13 / 13) Lines: 100% (51 / 51) Ignored: none

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

    1

    2

    4

    2

    1

    1

    1

    1

    1
    1

    1
    1

    1
    1

    1
    1
    3

    1

    1
    1
    1
    1
    1
    3

    1

    1

    1
    1

    1
    3

    3
    3
    3
    3

    1
    10

    1
    3
    3
    3
    1
    1

    1

    1
    8

    1
    1
    1
    3

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

    var _Subscriber3 = _interopRequireDefault(_Subscriber2);

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

        function ForkJoinObservable(observables) {
            _classCallCheck(this, ForkJoinObservable);

            _Observable.call(this);
            this.observables = observables;
        }

        ForkJoinObservable.create = function create() {
            for (var _len = arguments.length, observables = Array(_len), _key = 0; _key < _len; _key++) {
                observables[_key] = arguments[_key];
            }

            return new ForkJoinObservable(observables);
        };

        ForkJoinObservable.prototype._subscribe = function _subscribe(subscriber) {
            var observables = this.observables;
            var len = observables.length;
            var context = { complete: 0, total: len, values: emptyArray(len) };
            for (var i = 0; i < len; i++) {
                observables[i].subscribe(new AllSubscriber(subscriber, this, i, context));
            }
        };

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

    exports['default'] = ForkJoinObservable;

    var AllSubscriber = (function (_Subscriber) {
        _inherits(AllSubscriber, _Subscriber);

        function AllSubscriber(destination, parent, index, context) {
            _classCallCheck(this, AllSubscriber);

            _Subscriber.call(this, destination);
            this.parent = parent;
            this.index = index;
            this.context = context;
        }

        AllSubscriber.prototype._next = function _next(value) {
            this._value = value;
        };

        AllSubscriber.prototype._complete = function _complete() {
            var context = this.context;
            context.values[this.index] = this._value;
            if (context.values.every(hasValue)) {
                this.destination.next(context.values);
                this.destination.complete();
            }
        };

        return AllSubscriber;
    })(_Subscriber3['default']);

    function hasValue(x) {
        return x !== null;
    }
    function emptyArray(len) {
        var arr = [];
        for (var i = 0; i < len; i++) {
            arr.push(null);
        }
        return arr;
    }
    module.exports = exports['default'];