42
42
import rx .operators .OperationConcat ;
43
43
import rx .operators .OperationDefer ;
44
44
import rx .operators .OperationDematerialize ;
45
- import rx .operators .OperationGroupBy ;
46
45
import rx .operators .OperationFilter ;
47
46
import rx .operators .OperationFinally ;
47
+ import rx .operators .OperationGroupBy ;
48
48
import rx .operators .OperationMap ;
49
49
import rx .operators .OperationMaterialize ;
50
50
import rx .operators .OperationMerge ;
64
64
import rx .operators .OperationTakeLast ;
65
65
import rx .operators .OperationTakeUntil ;
66
66
import rx .operators .OperationTakeWhile ;
67
+ import rx .operators .OperationToFuture ;
67
68
import rx .operators .OperationToIterator ;
68
69
import rx .operators .OperationToObservableFuture ;
69
70
import rx .operators .OperationToObservableIterable ;
@@ -590,9 +591,11 @@ public void call(Object args) {
590
591
591
592
/**
592
593
* Returns a connectable observable sequence that upon connection causes the source sequence to push results into the specified subject.
593
- *
594
- * @param subject the subject to push source elements into.
595
- * @param <R> result type
594
+ *
595
+ * @param subject
596
+ * the subject to push source elements into.
597
+ * @param <R>
598
+ * result type
596
599
* @return a connectable observable sequence that upon connection causes the source sequence to push results into the specified subject.
597
600
*/
598
601
public <R > ConnectableObservable <R > multicast (Subject <T , R > subject ) {
@@ -1172,6 +1175,8 @@ public R call(T t1) {
1172
1175
* and then merges the results of that function applied to every item emitted by the original
1173
1176
* Observable, emitting these merged results as its own sequence.
1174
1177
* <p>
1178
+ * Note: mapMany and flatMap are equivalent.
1179
+ * <p>
1175
1180
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/mapMany.png">
1176
1181
*
1177
1182
* @param sequence
@@ -1186,6 +1191,7 @@ public R call(T t1) {
1186
1191
* @return an Observable that emits a sequence that is the result of applying the transformation
1187
1192
* function to each item emitted by the source Observable and merging the results of
1188
1193
* the Observables obtained from this transformation
1194
+ * @see {@link #flatMap(Observable, Func1)}
1189
1195
*/
1190
1196
public static <T , R > Observable <R > mapMany (Observable <T > sequence , Func1 <T , Observable <R >> func ) {
1191
1197
return create (OperationMap .mapMany (sequence , func ));
@@ -1351,6 +1357,62 @@ public static <T> Observable<T> finallyDo(Observable<T> source, Action0 action)
1351
1357
return create (OperationFinally .finallyDo (source , action ));
1352
1358
}
1353
1359
1360
+ /**
1361
+ * Creates a new Observable sequence by applying a function that you supply to each object in the
1362
+ * original Observable sequence, where that function is itself an Observable that emits objects,
1363
+ * and then merges the results of that function applied to every item emitted by the original
1364
+ * Observable, emitting these merged results as its own sequence.
1365
+ * <p>
1366
+ * Note: mapMany and flatMap are equivalent.
1367
+ * <p>
1368
+ * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/mapMany.png">
1369
+ *
1370
+ * @param sequence
1371
+ * the source Observable
1372
+ * @param func
1373
+ * a function to apply to each item emitted by the source Observable, generating a
1374
+ * Observable
1375
+ * @param <T>
1376
+ * the type emitted by the source Observable
1377
+ * @param <R>
1378
+ * the type emitted by the Observables emitted by <code>func</code>
1379
+ * @return an Observable that emits a sequence that is the result of applying the transformation
1380
+ * function to each item emitted by the source Observable and merging the results of
1381
+ * the Observables obtained from this transformation
1382
+ * @see {@link #mapMany(Observable, Func1)}
1383
+ */
1384
+ public static <T , R > Observable <R > flatMap (Observable <T > sequence , Func1 <T , Observable <R >> func ) {
1385
+ return mapMany (sequence , func );
1386
+ }
1387
+
1388
+ /**
1389
+ * Creates a new Observable sequence by applying a function that you supply to each object in the
1390
+ * original Observable sequence, where that function is itself an Observable that emits objects,
1391
+ * and then merges the results of that function applied to every item emitted by the original
1392
+ * Observable, emitting these merged results as its own sequence.
1393
+ * <p>
1394
+ * Note: mapMany and flatMap are equivalent.
1395
+ * <p>
1396
+ * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/mapMany.png">
1397
+ *
1398
+ * @param sequence
1399
+ * the source Observable
1400
+ * @param func
1401
+ * a function to apply to each item emitted by the source Observable, generating a
1402
+ * Observable
1403
+ * @param <T>
1404
+ * the type emitted by the source Observable
1405
+ * @param <R>
1406
+ * the type emitted by the Observables emitted by <code>func</code>
1407
+ * @return an Observable that emits a sequence that is the result of applying the transformation
1408
+ * function to each item emitted by the source Observable and merging the results of
1409
+ * the Observables obtained from this transformation
1410
+ * @see {@link #mapMany(Observable, Func1)}
1411
+ */
1412
+ public static <T , R > Observable <R > flatMap (Observable <T > sequence , final Object func ) {
1413
+ return mapMany (sequence , func );
1414
+ }
1415
+
1354
1416
/**
1355
1417
* Groups the elements of an observable and selects the resulting elements by using a specified function.
1356
1418
*
@@ -2005,6 +2067,19 @@ public Boolean call(T t, Integer integer)
2005
2067
}));
2006
2068
}
2007
2069
2070
+ /**
2071
+ * Return a Future representing a single value of the Observable.
2072
+ * <p>
2073
+ * This will throw an exception if the Observable emits more than 1 value. If more than 1 are expected then use <code>toList().toFuture()</code>.
2074
+ *
2075
+ * @param that
2076
+ * the source Observable
2077
+ * @returna Future that expects a single item emitted by the source Observable
2078
+ */
2079
+ public static <T > Future <T > toFuture (final Observable <T > that ) {
2080
+ return OperationToFuture .toFuture (that );
2081
+ }
2082
+
2008
2083
/**
2009
2084
* Returns an Observable that emits a single item, a list composed of all the items emitted by
2010
2085
* the source Observable.
@@ -2088,11 +2163,15 @@ public static <T> Iterable<T> mostRecent(Observable<T> source, T initialValue) {
2088
2163
2089
2164
/**
2090
2165
* Returns a connectable observable sequence that upon connection causes the source sequence to push results into the specified subject.
2091
- *
2092
- * @param source the source sequence whose elements will be pushed into the specified subject.
2093
- * @param subject the subject to push source elements into.
2094
- * @param <T> source type
2095
- * @param <R> result type
2166
+ *
2167
+ * @param source
2168
+ * the source sequence whose elements will be pushed into the specified subject.
2169
+ * @param subject
2170
+ * the subject to push source elements into.
2171
+ * @param <T>
2172
+ * source type
2173
+ * @param <R>
2174
+ * result type
2096
2175
* @return a connectable observable sequence that upon connection causes the source sequence to push results into the specified subject.
2097
2176
*/
2098
2177
public static <T , R > ConnectableObservable <R > multicast (Observable <T > source , final Subject <T , R > subject ) {
@@ -2101,7 +2180,7 @@ public static <T, R> ConnectableObservable<R> multicast(Observable<T> source, fi
2101
2180
2102
2181
/**
2103
2182
* Returns the only element of an observable sequence and throws an exception if there is not exactly one element in the observable sequence.
2104
- *
2183
+ *
2105
2184
* @param that
2106
2185
* the source Observable
2107
2186
* @return The single element in the observable sequence.
@@ -2670,6 +2749,48 @@ public Boolean call(T t1) {
2670
2749
});
2671
2750
}
2672
2751
2752
+ /**
2753
+ * Creates a new Observable sequence by applying a function that you supply to each item in the
2754
+ * original Observable sequence, where that function is itself an Observable that emits items, and
2755
+ * then merges the results of that function applied to every item emitted by the original
2756
+ * Observable, emitting these merged results as its own sequence.
2757
+ * <p>
2758
+ * Note: mapMany and flatMap are equivalent.
2759
+ * <p>
2760
+ * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/mapMany.png">
2761
+ *
2762
+ * @param func
2763
+ * a function to apply to each item in the sequence, that returns an Observable.
2764
+ * @return an Observable that emits a sequence that is the result of applying the transformation
2765
+ * function to each item in the input sequence and merging the results of the
2766
+ * Observables obtained from this transformation.
2767
+ * @see {@link #mapMany(Func1)}
2768
+ */
2769
+ public <R > Observable <R > flatMap (Func1 <T , Observable <R >> func ) {
2770
+ return mapMany (func );
2771
+ }
2772
+
2773
+ /**
2774
+ * Creates a new Observable sequence by applying a function that you supply to each item in the
2775
+ * original Observable sequence, where that function is itself an Observable that emits items, and
2776
+ * then merges the results of that function applied to every item emitted by the original
2777
+ * Observable, emitting these merged results as its own sequence.
2778
+ * <p>
2779
+ * Note: mapMany and flatMap are equivalent.
2780
+ * <p>
2781
+ * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/mapMany.png">
2782
+ *
2783
+ * @param callback
2784
+ * a function to apply to each item in the sequence that returns an Observable.
2785
+ * @return an Observable that emits a sequence that is the result of applying the transformation'
2786
+ * function to each item in the input sequence and merging the results of the
2787
+ * Observables obtained from this transformation.
2788
+ * @see {@link #mapMany(Object)}
2789
+ */
2790
+ public <R > Observable <R > flatMap (final Object callback ) {
2791
+ return mapMany (callback );
2792
+ }
2793
+
2673
2794
/**
2674
2795
* Filters an Observable by discarding any of its emissions that do not meet some test.
2675
2796
* <p>
@@ -2805,13 +2926,16 @@ public R call(T t1) {
2805
2926
* then merges the results of that function applied to every item emitted by the original
2806
2927
* Observable, emitting these merged results as its own sequence.
2807
2928
* <p>
2929
+ * Note: mapMany and flatMap are equivalent.
2930
+ * <p>
2808
2931
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/mapMany.png">
2809
2932
*
2810
2933
* @param func
2811
2934
* a function to apply to each item in the sequence, that returns an Observable.
2812
2935
* @return an Observable that emits a sequence that is the result of applying the transformation
2813
2936
* function to each item in the input sequence and merging the results of the
2814
2937
* Observables obtained from this transformation.
2938
+ * @see {@link #flatMap(Func1)}
2815
2939
*/
2816
2940
public <R > Observable <R > mapMany (Func1 <T , Observable <R >> func ) {
2817
2941
return mapMany (this , func );
@@ -2823,13 +2947,16 @@ public <R> Observable<R> mapMany(Func1<T, Observable<R>> func) {
2823
2947
* then merges the results of that function applied to every item emitted by the original
2824
2948
* Observable, emitting these merged results as its own sequence.
2825
2949
* <p>
2950
+ * Note: mapMany and flatMap are equivalent.
2951
+ * <p>
2826
2952
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/mapMany.png">
2827
2953
*
2828
2954
* @param callback
2829
2955
* a function to apply to each item in the sequence that returns an Observable.
2830
2956
* @return an Observable that emits a sequence that is the result of applying the transformation'
2831
2957
* function to each item in the input sequence and merging the results of the
2832
2958
* Observables obtained from this transformation.
2959
+ * @see {@link #flatMap(Object))}
2833
2960
*/
2834
2961
public <R > Observable <R > mapMany (final Object callback ) {
2835
2962
@ SuppressWarnings ("rawtypes" )
@@ -3360,6 +3487,17 @@ public <E> Observable<T> takeUntil(Observable<E> other) {
3360
3487
return takeUntil (this , other );
3361
3488
}
3362
3489
3490
+ /**
3491
+ * Return a Future representing a single value of the Observable.
3492
+ * <p>
3493
+ * This will throw an exception if the Observable emits more than 1 value. If more than 1 are expected then use <code>toList().toFuture()</code>.
3494
+ *
3495
+ * @returna Future that expects a single item emitted by the source Observable
3496
+ */
3497
+ public Future <T > toFuture () {
3498
+ return toFuture (this );
3499
+ }
3500
+
3363
3501
/**
3364
3502
* Returns an Observable that emits a single item, a list composed of all the items emitted by
3365
3503
* the source Observable.
0 commit comments