Tumortisch-Dist/resources/app/node_modules/rxjs/operator/combineLatest.js
2021-06-15 16:00:08 +02:00

55 lines
2.4 KiB
JavaScript

"use strict";
var combineLatest_1 = require('../operators/combineLatest');
/* tslint:enable:max-line-length */
/**
* Combines multiple Observables to create an Observable whose values are
* calculated from the latest values of each of its input Observables.
*
* <span class="informal">Whenever any input Observable emits a value, it
* computes a formula using the latest values from all the inputs, then emits
* the output of that formula.</span>
*
* <img src="./img/combineLatest.png" width="100%">
*
* `combineLatest` combines the values from this Observable with values from
* Observables passed as arguments. This is done by subscribing to each
* Observable, in order, and collecting an array of each of the most recent
* values any time any of the input Observables emits, then either taking that
* array and passing it as arguments to an optional `project` function and
* emitting the return value of that, or just emitting the array of recent
* values directly if there is no `project` function.
*
* @example <caption>Dynamically calculate the Body-Mass Index from an Observable of weight and one for height</caption>
* var weight = Rx.Observable.of(70, 72, 76, 79, 75);
* var height = Rx.Observable.of(1.76, 1.77, 1.78);
* var bmi = weight.combineLatest(height, (w, h) => w / (h * h));
* bmi.subscribe(x => console.log('BMI is ' + x));
*
* // With output to console:
* // BMI is 24.212293388429753
* // BMI is 23.93948099205209
* // BMI is 23.671253629592222
*
* @see {@link combineAll}
* @see {@link merge}
* @see {@link withLatestFrom}
*
* @param {ObservableInput} other An input Observable to combine with the source
* Observable. More than one input Observables may be given as argument.
* @param {function} [project] An optional function to project the values from
* the combined latest values into a new value on the output Observable.
* @return {Observable} An Observable of projected values from the most recent
* values from each input Observable, or an array of the most recent values from
* each input Observable.
* @method combineLatest
* @owner Observable
*/
function combineLatest() {
var observables = [];
for (var _i = 0; _i < arguments.length; _i++) {
observables[_i - 0] = arguments[_i];
}
return combineLatest_1.combineLatest.apply(void 0, observables)(this);
}
exports.combineLatest = combineLatest;
//# sourceMappingURL=combineLatest.js.map