45 lines
1.5 KiB
JavaScript
45 lines
1.5 KiB
JavaScript
"use strict";
|
|
var ArrayObservable_1 = require('../observable/ArrayObservable');
|
|
var mergeAll_1 = require('./mergeAll');
|
|
var isScheduler_1 = require('../util/isScheduler');
|
|
/**
|
|
* Creates a result Observable which emits values from every given input Observable.
|
|
*
|
|
* <img src="./img/merge.png" width="100%">
|
|
*
|
|
* @param {Observable} input Observables
|
|
* @returns {Observable} an Observable that emits items that are the result of every input Observable.
|
|
*/
|
|
function merge() {
|
|
var observables = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
observables[_i - 0] = arguments[_i];
|
|
}
|
|
observables.unshift(this);
|
|
return mergeStatic.apply(this, observables);
|
|
}
|
|
exports.merge = merge;
|
|
function mergeStatic() {
|
|
var observables = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
observables[_i - 0] = arguments[_i];
|
|
}
|
|
var concurrent = Number.POSITIVE_INFINITY;
|
|
var scheduler = null;
|
|
var last = observables[observables.length - 1];
|
|
if (isScheduler_1.isScheduler(last)) {
|
|
scheduler = observables.pop();
|
|
if (observables.length > 1 && typeof observables[observables.length - 1] === 'number') {
|
|
concurrent = observables.pop();
|
|
}
|
|
}
|
|
else if (typeof last === 'number') {
|
|
concurrent = observables.pop();
|
|
}
|
|
if (observables.length === 1) {
|
|
return observables[0];
|
|
}
|
|
return new ArrayObservable_1.ArrayObservable(observables, scheduler).lift(new mergeAll_1.MergeAllOperator(concurrent));
|
|
}
|
|
exports.mergeStatic = mergeStatic;
|
|
//# sourceMappingURL=merge.js.map
|