1 |
|
---|
2 | import { isArray } from '../util/isArray';
|
---|
3 | import { CombineLatestOperator } from '../observable/combineLatest';
|
---|
4 | import { from } from '../observable/from';
|
---|
5 | import { Observable } from '../Observable';
|
---|
6 | import { ObservableInput, OperatorFunction } from '../types';
|
---|
7 |
|
---|
8 | const none = {};
|
---|
9 |
|
---|
10 | /* tslint:disable:max-line-length */
|
---|
11 | /** @deprecated Deprecated in favor of static combineLatest. */
|
---|
12 | export function combineLatest<T, R>(project: (v1: T) => R): OperatorFunction<T, R>;
|
---|
13 | /** @deprecated Deprecated in favor of static combineLatest. */
|
---|
14 | export function combineLatest<T, T2, R>(v2: ObservableInput<T2>, project: (v1: T, v2: T2) => R): OperatorFunction<T, R>;
|
---|
15 | /** @deprecated Deprecated in favor of static combineLatest. */
|
---|
16 | export function combineLatest<T, T2, T3, R>(v2: ObservableInput<T2>, v3: ObservableInput<T3>, project: (v1: T, v2: T2, v3: T3) => R): OperatorFunction<T, R>;
|
---|
17 | /** @deprecated Deprecated in favor of static combineLatest. */
|
---|
18 | export function combineLatest<T, T2, T3, T4, R>(v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, project: (v1: T, v2: T2, v3: T3, v4: T4) => R): OperatorFunction<T, R>;
|
---|
19 | /** @deprecated Deprecated in favor of static combineLatest. */
|
---|
20 | export function combineLatest<T, T2, T3, T4, T5, R>(v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, v5: ObservableInput<T5>, project: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => R): OperatorFunction<T, R>;
|
---|
21 | /** @deprecated Deprecated in favor of static combineLatest. */
|
---|
22 | export function combineLatest<T, T2, T3, T4, T5, T6, R>(v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, v5: ObservableInput<T5>, v6: ObservableInput<T6>, project: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6) => R): OperatorFunction<T, R> ;
|
---|
23 | /** @deprecated Deprecated in favor of static combineLatest. */
|
---|
24 | export function combineLatest<T, T2>(v2: ObservableInput<T2>): OperatorFunction<T, [T, T2]>;
|
---|
25 | /** @deprecated Deprecated in favor of static combineLatest. */
|
---|
26 | export function combineLatest<T, T2, T3>(v2: ObservableInput<T2>, v3: ObservableInput<T3>): OperatorFunction<T, [T, T2, T3]>;
|
---|
27 | /** @deprecated Deprecated in favor of static combineLatest. */
|
---|
28 | export function combineLatest<T, T2, T3, T4>(v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>): OperatorFunction<T, [T, T2, T3, T4]>;
|
---|
29 | /** @deprecated Deprecated in favor of static combineLatest. */
|
---|
30 | export function combineLatest<T, T2, T3, T4, T5>(v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, v5: ObservableInput<T5>): OperatorFunction<T, [T, T2, T3, T4, T5]>;
|
---|
31 | /** @deprecated Deprecated in favor of static combineLatest. */
|
---|
32 | export function combineLatest<T, T2, T3, T4, T5, T6>(v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, v5: ObservableInput<T5>, v6: ObservableInput<T6>): OperatorFunction<T, [T, T2, T3, T4, T5, T6]> ;
|
---|
33 | /** @deprecated Deprecated in favor of static combineLatest. */
|
---|
34 | export function combineLatest<T, R>(...observables: Array<ObservableInput<T> | ((...values: Array<T>) => R)>): OperatorFunction<T, R>;
|
---|
35 | /** @deprecated Deprecated in favor of static combineLatest. */
|
---|
36 | export function combineLatest<T, R>(array: ObservableInput<T>[]): OperatorFunction<T, Array<T>>;
|
---|
37 | /** @deprecated Deprecated in favor of static combineLatest. */
|
---|
38 | export function combineLatest<T, TOther, R>(array: ObservableInput<TOther>[], project: (v1: T, ...values: Array<TOther>) => R): OperatorFunction<T, R>;
|
---|
39 | /* tslint:enable:max-line-length */
|
---|
40 |
|
---|
41 | /**
|
---|
42 | * @deprecated Deprecated in favor of static {@link combineLatest}.
|
---|
43 | */
|
---|
44 | export function combineLatest<T, R>(...observables: Array<ObservableInput<any> |
|
---|
45 | Array<ObservableInput<any>> |
|
---|
46 | ((...values: Array<any>) => R)>): OperatorFunction<T, R> {
|
---|
47 | let project: (...values: Array<any>) => R = null;
|
---|
48 | if (typeof observables[observables.length - 1] === 'function') {
|
---|
49 | project = <(...values: Array<any>) => R>observables.pop();
|
---|
50 | }
|
---|
51 |
|
---|
52 | // if the first and only other argument besides the resultSelector is an array
|
---|
53 | // assume it's been called with `combineLatest([obs1, obs2, obs3], project)`
|
---|
54 | if (observables.length === 1 && isArray(observables[0])) {
|
---|
55 | observables = (<any>observables[0]).slice();
|
---|
56 | }
|
---|
57 |
|
---|
58 | return (source: Observable<T>) => source.lift.call(from([source, ...observables]), new CombineLatestOperator(project));
|
---|
59 | }
|
---|