Skip to content

Commit de66728

Browse files
author
jmhofer
committed
re-added combineLatest methods that got lost due to too optimistic super/extends generics
1 parent 077b148 commit de66728

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

rxjava-core/src/main/java/rx/Observable.java

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
*/
1616
package rx;
1717

18-
import static org.junit.Assert.*;
19-
import static org.mockito.Matchers.*;
20-
import static org.mockito.Mockito.*;
21-
2218
import java.util.ArrayList;
2319
import java.util.Arrays;
2420
import java.util.Collection;
@@ -27,14 +23,14 @@
2723
import java.util.concurrent.Future;
2824
import java.util.concurrent.TimeUnit;
2925

30-
3126
import rx.concurrency.Schedulers;
3227
import rx.observables.BlockingObservable;
3328
import rx.observables.ConnectableObservable;
3429
import rx.observables.GroupedObservable;
3530
import rx.operators.OperationAll;
3631
import rx.operators.OperationBuffer;
3732
import rx.operators.OperationCache;
33+
import rx.operators.OperationCombineLatest;
3834
import rx.operators.OperationConcat;
3935
import rx.operators.OperationDefer;
4036
import rx.operators.OperationDematerialize;
@@ -1085,6 +1081,38 @@ public static <R, T0, T1, T2, T3> Observable<R> zip(Observable<T0> w0, Observabl
10851081
return create(OperationZip.zip(w0, w1, w2, w3, reduceFunction));
10861082
}
10871083

1084+
/**
1085+
* Combines the given observables, emitting an event containing an aggregation of the latest values of each of the source observables
1086+
* each time an event is received from one of the source observables, where the aggregation is defined by the given function.
1087+
* <p>
1088+
* <img width="640" src="https://github.com/Netflix/RxJava/wiki/images/rx-operators/combineLatest.png">
1089+
*
1090+
* @param w0
1091+
* The first source observable.
1092+
* @param w1
1093+
* The second source observable.
1094+
* @param combineFunction
1095+
* The aggregation function used to combine the source observable values.
1096+
* @return An Observable that combines the source Observables with the given combine function
1097+
*/
1098+
public static <R, T0, T1> Observable<R> combineLatest(Observable<T0> w0, Observable<T1> w1, Func2<T0, T1, R> combineFunction) {
1099+
return create(OperationCombineLatest.combineLatest(w0, w1, combineFunction));
1100+
}
1101+
1102+
/**
1103+
* @see #combineLatest(Observable, Observable, Func2)
1104+
*/
1105+
public static <R, T0, T1, T2> Observable<R> combineLatest(Observable<T0> w0, Observable<T1> w1, Observable<T2> w2, Func3<T0, T1, T2, R> combineFunction) {
1106+
return create(OperationCombineLatest.combineLatest(w0, w1, w2, combineFunction));
1107+
}
1108+
1109+
/**
1110+
* @see #combineLatest(Observable, Observable, Func2)
1111+
*/
1112+
public static <R, T0, T1, T2, T3> Observable<R> combineLatest(Observable<T0> w0, Observable<T1> w1, Observable<T2> w2, Observable<T3> w3, Func4<T0, T1, T2, T3, R> combineFunction) {
1113+
return create(OperationCombineLatest.combineLatest(w0, w1, w2, w3, combineFunction));
1114+
}
1115+
10881116
/**
10891117
* Creates an Observable which produces buffers of collected values.
10901118
*

0 commit comments

Comments
 (0)