Skip to content

Commit 0356d4f

Browse files
Merge pull request #1494 from benjchristensen/zip-with
zipWith
2 parents d9c628d + 83b4729 commit 0356d4f

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6278,7 +6278,7 @@ public final Observable<T> retry(Func2<Integer, Throwable, Boolean> predicate) {
62786278
* System.out.println("subscribing");
62796279
* s.onError(new RuntimeException("always fails"));
62806280
* }).retryWhen(attempts -> {
6281-
* return attempts.zip(Observable.range(1, 3), (n, i) -> i).flatMap(i -> {
6281+
* return attempts.zipWith(Observable.range(1, 3), (n, i) -> i).flatMap(i -> {
62826282
* System.out.println("delay retry by " + i + " second(s)");
62836283
* return Observable.timer(i, TimeUnit.SECONDS);
62846284
* });
@@ -8971,10 +8971,38 @@ public final <T2, R> Observable<R> zip(Iterable<? extends T2> other, Func2<? sup
89718971
* and emits the results of {@code zipFunction} applied to these pairs
89728972
* @see <a href="https://github.com/Netflix/RxJava/wiki/Combining-Observables#zip">RxJava wiki: zip</a>
89738973
* @see <a href="http://msdn.microsoft.com/en-us/library/system.reactive.linq.observable.zip.aspx">MSDN: Observable.Zip</a>
8974+
* @deprecated Use zipWith instead. Changed to match naming convention of mergeWith, concatWith, etc
89748975
*/
8976+
@Deprecated
89758977
public final <T2, R> Observable<R> zip(Observable<? extends T2> other, Func2<? super T, ? super T2, ? extends R> zipFunction) {
89768978
return zip(this, other, zipFunction);
89778979
}
8980+
8981+
/**
8982+
* Returns an Observable that emits items that are the result of applying a specified function to pairs of
8983+
* values, one each from the source Observable and another specified Observable.
8984+
* <p>
8985+
* <img width="640" height="380" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/zip.png" alt="">
8986+
* <p>
8987+
* {@code zip} does not operate by default on a particular {@link Scheduler}.
8988+
*
8989+
* @param <T2>
8990+
* the type of items emitted by the {@code other} Observable
8991+
* @param <R>
8992+
* the type of items emitted by the resulting Observable
8993+
* @param other
8994+
* the other Observable
8995+
* @param zipFunction
8996+
* a function that combines the pairs of items from the two Observables to generate the items to
8997+
* be emitted by the resulting Observable
8998+
* @return an Observable that pairs up values from the source Observable and the {@code other} Observable
8999+
* and emits the results of {@code zipFunction} applied to these pairs
9000+
* @see <a href="https://github.com/Netflix/RxJava/wiki/Combining-Observables#zip">RxJava wiki: zip</a>
9001+
* @see <a href="http://msdn.microsoft.com/en-us/library/system.reactive.linq.observable.zip.aspx">MSDN: Observable.Zip</a>
9002+
*/
9003+
public final <T2, R> Observable<R> zipWith(Observable<? extends T2> other, Func2<? super T, ? super T2, ? extends R> zipFunction) {
9004+
return zip(this, other, zipFunction);
9005+
}
89789006

89799007
/**
89809008
* An Observable that never sends any information to an {@link Observer}.

0 commit comments

Comments
 (0)