@@ -2,6 +2,7 @@ import {Observable} from '../Observable';
22import { ArrayObservable } from '../observable/fromArray' ;
33import { CombineLatestOperator } from './combineLatest-support' ;
44import { isArray } from '../util/isArray' ;
5+ import { ObservableInput } from '../types' ;
56
67/**
78 * Combines the values from this observable with values from observables passed as arguments. This is done by subscribing
@@ -13,18 +14,58 @@ import {isArray} from '../util/isArray';
1314 * @returns {Observable } an observable of other projected values from the most recent values from each observable, or an array of each of
1415 * the most recent values from each observable.
1516 */
16- export function combineLatest < R > ( ...observables : Array < Observable < any > |
17- Array < Observable < any > > |
18- ( ( ...values : Array < any > ) => R ) > ) : Observable < R > {
19- let project : ( ...values : Array < any > ) => R = null ;
17+ export function combineLatest < T , TResult > ( project : ( v1 : T ) => TResult ) : Observable < TResult > ;
18+ export function combineLatest < T , TResult > ( project : ( v1 : T ) => TResult ) : Observable < TResult > ;
19+ export function combineLatest < T , T2 > ( second : ObservableInput < T2 > ) : Observable < [ T , T2 ] > ;
20+ export function combineLatest < T , T2 > ( array : [ ObservableInput < T2 > ] ) : Observable < [ T , T2 ] > ;
21+ export function combineLatest < T , T2 , TResult > ( second : ObservableInput < T2 > ,
22+ project : ( v1 : T , v2 : T2 ) => TResult ) : Observable < TResult > ;
23+ export function combineLatest < T , T2 , TResult > ( array : [
24+ ObservableInput < T2 >
25+ ] , project : ( v1 : T , v2 : T2 ) => TResult ) : Observable < TResult > ;
26+ export function combineLatest < T , T2 , T3 > ( second : ObservableInput < T2 > , third : ObservableInput < T3 > ) : Observable < [ T , T2 , T3 ] > ;
27+ export function combineLatest < T , T2 , T3 > ( array : [
28+ ObservableInput < T2 > ,
29+ ObservableInput < T3 >
30+ ] ) : Observable < [ T , T2 , T3 ] > ;
31+ export function combineLatest < T , T2 , T3 , TResult > ( second : ObservableInput < T2 > ,
32+ third : ObservableInput < T3 > ,
33+ project : ( v1 : T , v2 : T2 , v3 : T3 ) => TResult ) : Observable < TResult > ;
34+ export function combineLatest < T , T2 , T3 , TResult > ( array : [ ObservableInput < T2 > , ObservableInput < T3 > ] ,
35+ project : ( v1 : T , v2 : T2 , v3 : T3 ) => TResult ) : Observable < TResult > ;
36+ export function combineLatest < T , T2 , T3 , T4 > ( second : ObservableInput < T2 > ,
37+ third : ObservableInput < T3 > ,
38+ forth : ObservableInput < T4 > ) : Observable < [ T , T2 , T3 , T4 ] > ;
39+ export function combineLatest < T , T2 , T3 , T4 > ( array : [
40+ ObservableInput < T2 > ,
41+ ObservableInput < T3 > ,
42+ ObservableInput < T4 >
43+ ] ) : Observable < [ T , T2 , T3 , T4 ] > ;
44+ export function combineLatest < T , T2 , T3 , T4 , TResult > ( second : ObservableInput < T2 > ,
45+ third : ObservableInput < T3 > ,
46+ forth : ObservableInput < T4 > ,
47+ project : ( v1 : T , v2 : T2 , v3 : T3 , v4 : T4 ) => TResult ) : Observable < TResult > ;
48+ export function combineLatest < T , T2 , T3 , T4 , TResult > ( array : [
49+ ObservableInput < T2 > ,
50+ ObservableInput < T3 > ,
51+ ObservableInput < T4 >
52+ ] ,
53+ project : ( v1 : T , v2 : T2 , v3 : T3 , v4 : T4 ) => TResult ) : Observable < TResult > ;
54+ export function combineLatest < T , TResult > ( array : ObservableInput < any > [ ] , project ?: Function ) : Observable < TResult [ ] > ;
55+ export function combineLatest < T > ( ...observables : Array < ObservableInput < T > > ) : Observable < T [ ] > ;
56+ export function combineLatest < T , R > ( ...observables : Array < ObservableInput < T > | ( ( ...values : Array < T > ) => R ) > ) : Observable < R > ;
57+ export function combineLatest < R > ( ...observables : Array < any | Observable < any > |
58+ Array < Promise < any > > |
59+ ( ( ...values : Array < any > ) => R ) > ) : Observable < R > {
60+ let project : ( ...values : Array < any > ) => R = null ;
2061 if ( typeof observables [ observables . length - 1 ] === 'function' ) {
2162 project = < ( ...values : Array < any > ) => R > observables . pop ( ) ;
2263 }
2364
2465 // if the first and only other argument besides the resultSelector is an array
2566 // assume it's been called with `combineLatest([obs1, obs2, obs3], project)`
2667 if ( observables . length === 1 && isArray ( observables [ 0 ] ) ) {
27- observables = < Array < Observable < any > > > observables [ 0 ] ;
68+ observables = < any > observables [ 0 ] ;
2869 }
2970
3071 observables . unshift ( this ) ;
0 commit comments