Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zipWith #1494

Merged
merged 1 commit into from
Jul 23, 2014
Merged

zipWith #1494

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion rxjava-core/src/main/java/rx/Observable.java
Original file line number Diff line number Diff line change
Expand Up @@ -6278,7 +6278,7 @@ public final Observable<T> retry(Func2<Integer, Throwable, Boolean> predicate) {
* System.out.println("subscribing");
* s.onError(new RuntimeException("always fails"));
* }).retryWhen(attempts -> {
* return attempts.zip(Observable.range(1, 3), (n, i) -> i).flatMap(i -> {
* return attempts.zipWith(Observable.range(1, 3), (n, i) -> i).flatMap(i -> {
* System.out.println("delay retry by " + i + " second(s)");
* return Observable.timer(i, TimeUnit.SECONDS);
* });
Expand Down Expand Up @@ -8971,10 +8971,38 @@ public final <T2, R> Observable<R> zip(Iterable<? extends T2> other, Func2<? sup
* and emits the results of {@code zipFunction} applied to these pairs
* @see <a href="https://github.com/Netflix/RxJava/wiki/Combining-Observables#zip">RxJava wiki: zip</a>
* @see <a href="http://msdn.microsoft.com/en-us/library/system.reactive.linq.observable.zip.aspx">MSDN: Observable.Zip</a>
* @deprecated Use zipWith instead. Changed to match naming convention of mergeWith, concatWith, etc
*/
@Deprecated
public final <T2, R> Observable<R> zip(Observable<? extends T2> other, Func2<? super T, ? super T2, ? extends R> zipFunction) {
return zip(this, other, zipFunction);
}

/**
* Returns an Observable that emits items that are the result of applying a specified function to pairs of
* values, one each from the source Observable and another specified Observable.
* <p>
* <img width="640" height="380" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/zip.png" alt="">
* <p>
* {@code zip} does not operate by default on a particular {@link Scheduler}.
*
* @param <T2>
* the type of items emitted by the {@code other} Observable
* @param <R>
* the type of items emitted by the resulting Observable
* @param other
* the other Observable
* @param zipFunction
* a function that combines the pairs of items from the two Observables to generate the items to
* be emitted by the resulting Observable
* @return an Observable that pairs up values from the source Observable and the {@code other} Observable
* and emits the results of {@code zipFunction} applied to these pairs
* @see <a href="https://github.com/Netflix/RxJava/wiki/Combining-Observables#zip">RxJava wiki: zip</a>
* @see <a href="http://msdn.microsoft.com/en-us/library/system.reactive.linq.observable.zip.aspx">MSDN: Observable.Zip</a>
*/
public final <T2, R> Observable<R> zipWith(Observable<? extends T2> other, Func2<? super T, ? super T2, ? extends R> zipFunction) {
return zip(this, other, zipFunction);
}

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