Skip to content

Commit ebaa616

Browse files
author
Joachim Hofer
committed
Merge pull request #1 from benjchristensen/super-extends-additions
Zip and CombineLatest Operators: Generic Order and More Arities
2 parents 6b9867c + ac6a0a1 commit ebaa616

File tree

4 files changed

+411
-48
lines changed

4 files changed

+411
-48
lines changed

language-adaptors/rxjava-scala/build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ sourceSets {
2121
}
2222

2323
dependencies {
24-
compile 'org.scala-lang:scala-library:2.10.2'
24+
// pinning to 2.10.1 as having issues with 2.10.2
25+
compile 'org.scala-lang:scala-library:2.10.1'
2526

2627
compile project(':rxjava-core')
2728

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

+225-32
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@
8383
import rx.util.functions.Func2;
8484
import rx.util.functions.Func3;
8585
import rx.util.functions.Func4;
86+
import rx.util.functions.Func5;
87+
import rx.util.functions.Func6;
88+
import rx.util.functions.Func7;
89+
import rx.util.functions.Func8;
90+
import rx.util.functions.Func9;
8691
import rx.util.functions.FuncN;
8792
import rx.util.functions.Function;
8893

@@ -908,18 +913,17 @@ public static <T> Observable<T> from(Future<T> future, long timeout, TimeUnit un
908913
* The resulting {@code Observable<R>} returned from {@code zip} will invoke {@link Observer#onNext onNext} as many times as the number of {@code onNext} invocations
909914
* of the source Observable that emits the fewest items.
910915
*
911-
* @param w0
916+
* @param o1
912917
* one source Observable
913-
* @param w1
918+
* @param o2
914919
* another source Observable
915-
* @param reduceFunction
916-
* a function that, when applied to a pair of items, each emitted by one of the two
917-
* source Observables, results in an item that will be emitted by the resulting
918-
* Observable
920+
* @param zipFunction
921+
* a function that, when applied to an item emitted by each of the source
922+
* Observables, results in an item that will be emitted by the resulting Observable
919923
* @return an Observable that emits the zipped results
920924
*/
921-
public static <R, T0, T1> Observable<R> zip(Observable<? extends T0> w0, Observable<? extends T1> w1, Func2<? super T0, ? super T1, ? extends R> reduceFunction) {
922-
return create(OperationZip.zip(w0, w1, reduceFunction));
925+
public static <T1, T2, R> Observable<R> zip(Observable<? extends T1> o1, Observable<? extends T2> o2, Func2<? super T1, ? super T2, ? extends R> zipFunction) {
926+
return create(OperationZip.zip(o1, o2, zipFunction));
923927
}
924928

925929
/**
@@ -981,19 +985,19 @@ public static <T> Observable<Boolean> sequenceEqual(Observable<T> first, Observa
981985
* The resulting {@code Observable<R>} returned from {@code zip} will invoke {@link Observer#onNext onNext} as many times as the number of {@code onNext} invocations
982986
* of the source Observable that emits the fewest items.
983987
*
984-
* @param w0
988+
* @param o1
985989
* one source Observable
986-
* @param w1
987-
* another source Observable
988-
* @param w2
990+
* @param o2
991+
* a second source Observable
992+
* @param o3
989993
* a third source Observable
990-
* @param function
994+
* @param zipFunction
991995
* a function that, when applied to an item emitted by each of the source
992996
* Observables, results in an item that will be emitted by the resulting Observable
993997
* @return an Observable that emits the zipped results
994998
*/
995-
public static <R, T0, T1, T2> Observable<R> zip(Observable<? extends T0> w0, Observable<? extends T1> w1, Observable<? extends T2> w2, Func3<? super T0, ? super T1, ? super T2, ? extends R> function) {
996-
return create(OperationZip.zip(w0, w1, w2, function));
999+
public static <T1, T2, T3, R> Observable<R> zip(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Func3<? super T1, ? super T2, ? super T3, ? extends R> zipFunction) {
1000+
return create(OperationZip.zip(o1, o2, o3, zipFunction));
9971001
}
9981002

9991003
/**
@@ -1010,21 +1014,210 @@ public static <R, T0, T1, T2> Observable<R> zip(Observable<? extends T0> w0, Obs
10101014
* The resulting {@code Observable<R>} returned from {@code zip} will invoke {@link Observer#onNext onNext} as many times as the number of {@code onNext} invocations
10111015
* of the source Observable that emits the fewest items.
10121016
*
1013-
* @param w0
1017+
* @param o1
10141018
* one source Observable
1015-
* @param w1
1016-
* another source Observable
1017-
* @param w2
1019+
* @param o2
1020+
* a second source Observable
1021+
* @param o3
10181022
* a third source Observable
1019-
* @param w3
1023+
* @param o4
10201024
* a fourth source Observable
1021-
* @param reduceFunction
1025+
* @param zipFunction
1026+
* a function that, when applied to an item emitted by each of the source
1027+
* Observables, results in an item that will be emitted by the resulting Observable
1028+
* @return an Observable that emits the zipped results
1029+
*/
1030+
public static <T1, T2, T3, T4, R> Observable<R> zip(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Observable<? extends T4> o4, Func4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> zipFunction) {
1031+
return create(OperationZip.zip(o1, o2, o3, o4, zipFunction));
1032+
}
1033+
1034+
/**
1035+
* Returns an Observable that emits the results of a function of your choosing applied to
1036+
* combinations of four items emitted, in sequence, by four other Observables.
1037+
* <p>
1038+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/zip.png">
1039+
* <p> {@code zip} applies this function in strict sequence, so the first item emitted by the
1040+
* new Observable will be the result of the function applied to the first item emitted by {@code w0}, the first item emitted by {@code w1}, the first item emitted by {@code w2}, and the first item
1041+
* emitted by {@code w3}; the second item emitted by
1042+
* the new Observable will be the result of the function applied to the second item emitted by
1043+
* each of those Observables; and so forth.
1044+
* <p>
1045+
* The resulting {@code Observable<R>} returned from {@code zip} will invoke {@link Observer#onNext onNext} as many times as the number of {@code onNext} invocations
1046+
* of the source Observable that emits the fewest items.
1047+
*
1048+
* @param o1
1049+
* one source Observable
1050+
* @param o2
1051+
* a second source Observable
1052+
* @param o3
1053+
* a third source Observable
1054+
* @param o4
1055+
* a fourth source Observable
1056+
* @param o5
1057+
* a fifth source Observable
1058+
* @param zipFunction
1059+
* a function that, when applied to an item emitted by each of the source
1060+
* Observables, results in an item that will be emitted by the resulting Observable
1061+
* @return an Observable that emits the zipped results
1062+
*/
1063+
public static <T1, T2, T3, T4, T5, R> Observable<R> zip(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Observable<? extends T4> o4, Observable<? extends T5> o5, Func5<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? extends R> zipFunction) {
1064+
return create(OperationZip.zip(o1, o2, o3, o4, o5, zipFunction));
1065+
}
1066+
1067+
/**
1068+
* Returns an Observable that emits the results of a function of your choosing applied to
1069+
* combinations of four items emitted, in sequence, by four other Observables.
1070+
* <p>
1071+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/zip.png">
1072+
* <p> {@code zip} applies this function in strict sequence, so the first item emitted by the
1073+
* new Observable will be the result of the function applied to the first item emitted by {@code w0}, the first item emitted by {@code w1}, the first item emitted by {@code w2}, and the first item
1074+
* emitted by {@code w3}; the second item emitted by
1075+
* the new Observable will be the result of the function applied to the second item emitted by
1076+
* each of those Observables; and so forth.
1077+
* <p>
1078+
* The resulting {@code Observable<R>} returned from {@code zip} will invoke {@link Observer#onNext onNext} as many times as the number of {@code onNext} invocations
1079+
* of the source Observable that emits the fewest items.
1080+
*
1081+
* @param o1
1082+
* one source Observable
1083+
* @param o2
1084+
* a second source Observable
1085+
* @param o3
1086+
* a third source Observable
1087+
* @param o4
1088+
* a fourth source Observable
1089+
* @param o5
1090+
* a fifth source Observable
1091+
* @param o6
1092+
* a sixth source Observable
1093+
* @param zipFunction
1094+
* a function that, when applied to an item emitted by each of the source
1095+
* Observables, results in an item that will be emitted by the resulting Observable
1096+
* @return an Observable that emits the zipped results
1097+
*/
1098+
public static <T1, T2, T3, T4, T5, T6, R> Observable<R> zip(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Observable<? extends T4> o4, Observable<? extends T5> o5, Observable<? extends T6> o6,
1099+
Func6<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? extends R> zipFunction) {
1100+
return create(OperationZip.zip(o1, o2, o3, o4, o5, o6, zipFunction));
1101+
}
1102+
1103+
/**
1104+
* Returns an Observable that emits the results of a function of your choosing applied to
1105+
* combinations of four items emitted, in sequence, by four other Observables.
1106+
* <p>
1107+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/zip.png">
1108+
* <p> {@code zip} applies this function in strict sequence, so the first item emitted by the
1109+
* new Observable will be the result of the function applied to the first item emitted by {@code w0}, the first item emitted by {@code w1}, the first item emitted by {@code w2}, and the first item
1110+
* emitted by {@code w3}; the second item emitted by
1111+
* the new Observable will be the result of the function applied to the second item emitted by
1112+
* each of those Observables; and so forth.
1113+
* <p>
1114+
* The resulting {@code Observable<R>} returned from {@code zip} will invoke {@link Observer#onNext onNext} as many times as the number of {@code onNext} invocations
1115+
* of the source Observable that emits the fewest items.
1116+
*
1117+
* @param o1
1118+
* one source Observable
1119+
* @param o2
1120+
* a second source Observable
1121+
* @param o3
1122+
* a third source Observable
1123+
* @param o4
1124+
* a fourth source Observable
1125+
* @param o5
1126+
* a fifth source Observable
1127+
* @param o6
1128+
* a sixth source Observable
1129+
* @param o7
1130+
* a seventh source Observable
1131+
* @param zipFunction
10221132
* a function that, when applied to an item emitted by each of the source
10231133
* Observables, results in an item that will be emitted by the resulting Observable
10241134
* @return an Observable that emits the zipped results
10251135
*/
1026-
public static <R, T0, T1, T2, T3> Observable<R> zip(Observable<? extends T0> w0, Observable<? extends T1> w1, Observable<? extends T2> w2, Observable<? extends T3> w3, Func4<? super T0, ? super T1, ? super T2, ? super T3, ? extends R> reduceFunction) {
1027-
return create(OperationZip.zip(w0, w1, w2, w3, reduceFunction));
1136+
public static <T1, T2, T3, T4, T5, T6, T7, R> Observable<R> zip(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Observable<? extends T4> o4, Observable<? extends T5> o5, Observable<? extends T6> o6, Observable<? extends T7> o7,
1137+
Func7<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? extends R> zipFunction) {
1138+
return create(OperationZip.zip(o1, o2, o3, o4, o5, o6, o7, zipFunction));
1139+
}
1140+
1141+
/**
1142+
* Returns an Observable that emits the results of a function of your choosing applied to
1143+
* combinations of four items emitted, in sequence, by four other Observables.
1144+
* <p>
1145+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/zip.png">
1146+
* <p> {@code zip} applies this function in strict sequence, so the first item emitted by the
1147+
* new Observable will be the result of the function applied to the first item emitted by {@code w0}, the first item emitted by {@code w1}, the first item emitted by {@code w2}, and the first item
1148+
* emitted by {@code w3}; the second item emitted by
1149+
* the new Observable will be the result of the function applied to the second item emitted by
1150+
* each of those Observables; and so forth.
1151+
* <p>
1152+
* The resulting {@code Observable<R>} returned from {@code zip} will invoke {@link Observer#onNext onNext} as many times as the number of {@code onNext} invocations
1153+
* of the source Observable that emits the fewest items.
1154+
*
1155+
* @param o1
1156+
* one source Observable
1157+
* @param o2
1158+
* a second source Observable
1159+
* @param o3
1160+
* a third source Observable
1161+
* @param o4
1162+
* a fourth source Observable
1163+
* @param o5
1164+
* a fifth source Observable
1165+
* @param o6
1166+
* a sixth source Observable
1167+
* @param o7
1168+
* a seventh source Observable
1169+
* @param o8
1170+
* an eighth source Observable
1171+
* @param zipFunction
1172+
* a function that, when applied to an item emitted by each of the source
1173+
* Observables, results in an item that will be emitted by the resulting Observable
1174+
* @return an Observable that emits the zipped results
1175+
*/
1176+
public static <T1, T2, T3, T4, T5, T6, T7, T8, R> Observable<R> zip(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Observable<? extends T4> o4, Observable<? extends T5> o5, Observable<? extends T6> o6, Observable<? extends T7> o7, Observable<? extends T8> o8,
1177+
Func8<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, ? extends R> zipFunction) {
1178+
return create(OperationZip.zip(o1, o2, o3, o4, o5, o6, o7, o8, zipFunction));
1179+
}
1180+
1181+
/**
1182+
* Returns an Observable that emits the results of a function of your choosing applied to
1183+
* combinations of four items emitted, in sequence, by four other Observables.
1184+
* <p>
1185+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/zip.png">
1186+
* <p> {@code zip} applies this function in strict sequence, so the first item emitted by the
1187+
* new Observable will be the result of the function applied to the first item emitted by {@code w0}, the first item emitted by {@code w1}, the first item emitted by {@code w2}, and the first item
1188+
* emitted by {@code w3}; the second item emitted by
1189+
* the new Observable will be the result of the function applied to the second item emitted by
1190+
* each of those Observables; and so forth.
1191+
* <p>
1192+
* The resulting {@code Observable<R>} returned from {@code zip} will invoke {@link Observer#onNext onNext} as many times as the number of {@code onNext} invocations
1193+
* of the source Observable that emits the fewest items.
1194+
*
1195+
* @param o1
1196+
* one source Observable
1197+
* @param o2
1198+
* a second source Observable
1199+
* @param o3
1200+
* a third source Observable
1201+
* @param o4
1202+
* a fourth source Observable
1203+
* @param o5
1204+
* a fifth source Observable
1205+
* @param o6
1206+
* a sixth source Observable
1207+
* @param o7
1208+
* a seventh source Observable
1209+
* @param o8
1210+
* an eighth source Observable
1211+
* @param o9
1212+
* a ninth source Observable
1213+
* @param zipFunction
1214+
* a function that, when applied to an item emitted by each of the source
1215+
* Observables, results in an item that will be emitted by the resulting Observable
1216+
* @return an Observable that emits the zipped results
1217+
*/
1218+
public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, R> Observable<R> zip(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Observable<? extends T4> o4, Observable<? extends T5> o5, Observable<? extends T6> o6, Observable<? extends T7> o7, Observable<? extends T8> o8,
1219+
Observable<? extends T9> o9, Func9<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, ? super T9, ? extends R> zipFunction) {
1220+
return create(OperationZip.zip(o1, o2, o3, o4, o5, o6, o7, o8, o9, zipFunction));
10281221
}
10291222

10301223
/**
@@ -1033,30 +1226,30 @@ public static <R, T0, T1, T2, T3> Observable<R> zip(Observable<? extends T0> w0,
10331226
* <p>
10341227
* <img width="640" src="https://github.com/Netflix/RxJava/wiki/images/rx-operators/combineLatest.png">
10351228
*
1036-
* @param w0
1229+
* @param o1
10371230
* The first source observable.
1038-
* @param w1
1231+
* @param o2
10391232
* The second source observable.
10401233
* @param combineFunction
10411234
* The aggregation function used to combine the source observable values.
10421235
* @return An Observable that combines the source Observables with the given combine function
10431236
*/
1044-
public static <R, T0, T1> Observable<R> combineLatest(Observable<T0> w0, Observable<T1> w1, Func2<? super T0, ? super T1, ? extends R> combineFunction) {
1045-
return create(OperationCombineLatest.combineLatest(w0, w1, combineFunction));
1237+
public static <T1, T2, R> Observable<R> combineLatest(Observable<T1> o1, Observable<T2> o2, Func2<? super T1, ? super T2, ? extends R> combineFunction) {
1238+
return create(OperationCombineLatest.combineLatest(o1, o2, combineFunction));
10461239
}
10471240

10481241
/**
10491242
* @see #combineLatest(Observable, Observable, Func2)
10501243
*/
1051-
public static <R, T0, T1, T2> Observable<R> combineLatest(Observable<T0> w0, Observable<T1> w1, Observable<T2> w2, Func3<? super T0, ? super T1, ? super T2, ? extends R> combineFunction) {
1052-
return create(OperationCombineLatest.combineLatest(w0, w1, w2, combineFunction));
1244+
public static <T1, T2, T3, R> Observable<R> combineLatest(Observable<T1> o1, Observable<T2> o2, Observable<T3> o3, Func3<? super T1, ? super T2, ? super T3, ? extends R> combineFunction) {
1245+
return create(OperationCombineLatest.combineLatest(o1, o2, o3, combineFunction));
10531246
}
10541247

10551248
/**
10561249
* @see #combineLatest(Observable, Observable, Func2)
10571250
*/
1058-
public static <R, T0, T1, T2, T3> Observable<R> combineLatest(Observable<T0> w0, Observable<T1> w1, Observable<T2> w2, Observable<T3> w3, Func4<? super T0, ? super T1, ? super T2, ? super T3, ? extends R> combineFunction) {
1059-
return create(OperationCombineLatest.combineLatest(w0, w1, w2, w3, combineFunction));
1251+
public static <T1, T2, T3, T4, R> Observable<R> combineLatest(Observable<T1> o1, Observable<T2> o2, Observable<T3> o3, Observable<T4> o4, Func4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> combineFunction) {
1252+
return create(OperationCombineLatest.combineLatest(o1, o2, o3, o4, combineFunction));
10601253
}
10611254

10621255
/**
@@ -1307,7 +1500,7 @@ public Observable<R> call(List<Observable<?>> wsList) {
13071500
*
13081501
* @param ws
13091502
* A collection of source Observables
1310-
* @param reduceFunction
1503+
* @param zipFunction
13111504
* a function that, when applied to an item emitted by each of the source
13121505
* Observables, results in an item that will be emitted by the resulting Observable
13131506
* @return an Observable that emits the zipped results

0 commit comments

Comments
 (0)