/** PURE_IMPORTS_START .._util_isScheduler,.._util_isArray,._ArrayObservable,.._operators_combineLatest PURE_IMPORTS_END */ import { isScheduler } from '../util/isScheduler'; import { isArray } from '../util/isArray'; import { ArrayObservable } from './ArrayObservable'; import { CombineLatestOperator } from '../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. * * 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. * * * * `combineLatest` combines the values from all the Observables passed as * arguments. This is done by subscribing to each Observable in order and, * whenever any Observable emits, collecting an array of the most recent * values from each Observable. So if you pass `n` Observables to operator, * returned Observable will always emit an array of `n` values, in order * corresponding to order of passed Observables (value from the first Observable * on the first place and so on). * * Static version of `combineLatest` accepts either an array of Observables * or each Observable can be put directly as an argument. Note that array of * Observables is good choice, if you don't know beforehand how many Observables * you will combine. Passing empty array will result in Observable that * completes immediately. * * To ensure output array has always the same length, `combineLatest` will * actually wait for all input Observables to emit at least once, * before it starts emitting results. This means if some Observable emits * values before other Observables started emitting, all that values but last * will be lost. On the other hand, is some Observable does not emit value but * completes, resulting Observable will complete at the same moment without * emitting anything, since it will be now impossible to include value from * completed Observable in resulting array. Also, if some input Observable does * not emit any value and never completes, `combineLatest` will also never emit * and never complete, since, again, it will wait for all streams to emit some * value. * * If at least one Observable was passed to `combineLatest` and all passed Observables * emitted something, resulting Observable will complete when all combined * streams complete. So even if some Observable completes, result of * `combineLatest` will still emit values when other Observables do. In case * of completed Observable, its value from now on will always be the last * emitted value. On the other hand, if any Observable errors, `combineLatest` * will error immediately as well, and all other Observables will be unsubscribed. * * `combineLatest` accepts as optional parameter `project` function, which takes * as arguments all values that would normally be emitted by resulting Observable. * `project` can return any kind of value, which will be then emitted by Observable * instead of default array. Note that `project` does not take as argument that array * of values, but values themselves. That means default `project` can be imagined * as function that takes all its arguments and puts them into an array. * * * @example