Skip to content

Commit bb39cac

Browse files
author
jmhofer
committed
added combineLatest static methods to Observable
1 parent 4250d27 commit bb39cac

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import rx.observables.GroupedObservable;
4141
import rx.operators.OperationAll;
4242
import rx.operators.OperationCache;
43+
import rx.operators.OperationCombineLatest;
4344
import rx.operators.OperationConcat;
4445
import rx.operators.OperationDefer;
4546
import rx.operators.OperationDematerialize;
@@ -2737,6 +2738,35 @@ public R call(T0 t0, T1 t1, T2 t2, T3 t3) {
27372738
});
27382739
}
27392740

2741+
/**
2742+
* Combines the given observables, emitting an event containing an aggregation of the latest values of each of the source observables
2743+
* each time an event is received from one of the source observables, where the aggregation is defined by the given function.
2744+
* @param w0
2745+
* The first source observable.
2746+
* @param w1
2747+
* The second source observable.
2748+
* @param combineLatestFunction
2749+
* The aggregation function used to combine the source observable values.
2750+
* @return A function from an observer to a subscription. This can be used to create an observable from.
2751+
*/
2752+
public static <R, T0, T1> Observable<R> combineLatest(Observable<T0> w0, Observable<T1> w1, Func2<T0, T1, R> combineFunction) {
2753+
return create(OperationCombineLatest.combineLatest(w0, w1, combineFunction));
2754+
}
2755+
2756+
/**
2757+
* @see #combineLatest(Observable, Observable, Func2)
2758+
*/
2759+
public static <R, T0, T1, T2> Observable<R> combineLatest(Observable<T0> w0, Observable<T1> w1, Observable<T2> w2, Func3<T0, T1, T2, R> combineFunction) {
2760+
return create(OperationCombineLatest.combineLatest(w0, w1, w2, combineFunction));
2761+
}
2762+
2763+
/**
2764+
* @see #combineLatest(Observable, Observable, Func2)
2765+
*/
2766+
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) {
2767+
return create(OperationCombineLatest.combineLatest(w0, w1, w2, w3, combineFunction));
2768+
}
2769+
27402770
/**
27412771
* Filters an Observable by discarding any of its emissions that do not meet some test.
27422772
* <p>

0 commit comments

Comments
 (0)