Skip to content

Commit 52db70c

Browse files
Merge pull request #741 from akarnokd/ZipInstanceMethods
Zip with iterable, removed old aggregator version and updated tests
2 parents 68d7600 + 25910ee commit 52db70c

File tree

3 files changed

+524
-393
lines changed

3 files changed

+524
-393
lines changed

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2800,6 +2800,40 @@ public static <T1, T2, R> Observable<R> zip(Observable<? extends T1> o1, Observa
28002800
return create(OperationZip.zip(o1, o2, zipFunction));
28012801
}
28022802

2803+
/**
2804+
* Return an Observable that pairs up values from this Observable and the other
2805+
* Observable and applies a function.
2806+
* @param <T2> the other value type
2807+
* @param <R> the result type
2808+
* @param other the other Observable sequence
2809+
* @param zipFunction the function that combines the pairs of items from both
2810+
* observables and returns a new value
2811+
* @return an Observable that pairs up values from this Observable and the other
2812+
* Observable and applies a function.
2813+
*/
2814+
public <T2, R> Observable<R> zip(Observable<? extends T2> other, Func2<? super T, ? super T2, ? extends R> zipFunction) {
2815+
return zip(this, other, zipFunction);
2816+
}
2817+
2818+
/**
2819+
* Return an Observable that pairs up values from this Observable and an
2820+
* Iterable sequence and applies a function.
2821+
* <p>
2822+
* Note that the other Iterable is evaluated as items appear from this
2823+
* Observable and is not pre-consumed, allowing zipping infinite streams
2824+
* on either side.
2825+
* @param <T2> the other value type
2826+
* @param <R> the result type
2827+
* @param other the other Iterable sequence
2828+
* @param zipFunction the function that combines the pairs of items of
2829+
* this Observable and the Iterable
2830+
* @return an Observable that pairs up values from this Observable and an
2831+
* Iterable sequence and applies a function.
2832+
*/
2833+
public <T2, R> Observable<R> zip(Iterable<? extends T2> other, Func2<? super T, ? super T2, ? extends R> zipFunction) {
2834+
return create(OperationZip.zipIterable(this, other, zipFunction));
2835+
}
2836+
28032837
/**
28042838
* Returns an Observable that emits the results of a function of your
28052839
* choosing applied to combinations of three items emitted, in sequence, by

0 commit comments

Comments
 (0)