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 .OperationTimestamp ;
67
+ import rx .operators .OperationToFuture ;
68
68
import rx .operators .OperationToIterator ;
69
69
import rx .operators .OperationToObservableFuture ;
70
70
import rx .operators .OperationToObservableIterable ;
@@ -617,9 +617,11 @@ public void call(Object args) {
617
617
618
618
/**
619
619
* Returns a connectable observable sequence that upon connection causes the source sequence to push results into the specified subject.
620
- *
621
- * @param subject the subject to push source elements into.
622
- * @param <R> result type
620
+ *
621
+ * @param subject
622
+ * the subject to push source elements into.
623
+ * @param <R>
624
+ * result type
623
625
* @return a connectable observable sequence that upon connection causes the source sequence to push results into the specified subject.
624
626
*/
625
627
public <R > ConnectableObservable <R > multicast (Subject <T , R > subject ) {
@@ -1199,6 +1201,8 @@ public R call(T t1) {
1199
1201
* and then merges the results of that function applied to every item emitted by the original
1200
1202
* Observable, emitting these merged results as its own sequence.
1201
1203
* <p>
1204
+ * Note: mapMany and flatMap are equivalent.
1205
+ * <p>
1202
1206
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/mapMany.png">
1203
1207
*
1204
1208
* @param sequence
@@ -1213,6 +1217,7 @@ public R call(T t1) {
1213
1217
* @return an Observable that emits a sequence that is the result of applying the transformation
1214
1218
* function to each item emitted by the source Observable and merging the results of
1215
1219
* the Observables obtained from this transformation
1220
+ * @see {@link #flatMap(Observable, Func1)}
1216
1221
*/
1217
1222
public static <T , R > Observable <R > mapMany (Observable <T > sequence , Func1 <T , Observable <R >> func ) {
1218
1223
return create (OperationMap .mapMany (sequence , func ));
@@ -1378,6 +1383,62 @@ public static <T> Observable<T> finallyDo(Observable<T> source, Action0 action)
1378
1383
return create (OperationFinally .finallyDo (source , action ));
1379
1384
}
1380
1385
1386
+ /**
1387
+ * Creates a new Observable sequence by applying a function that you supply to each object in the
1388
+ * original Observable sequence, where that function is itself an Observable that emits objects,
1389
+ * and then merges the results of that function applied to every item emitted by the original
1390
+ * Observable, emitting these merged results as its own sequence.
1391
+ * <p>
1392
+ * Note: mapMany and flatMap are equivalent.
1393
+ * <p>
1394
+ * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/mapMany.png">
1395
+ *
1396
+ * @param sequence
1397
+ * the source Observable
1398
+ * @param func
1399
+ * a function to apply to each item emitted by the source Observable, generating a
1400
+ * Observable
1401
+ * @param <T>
1402
+ * the type emitted by the source Observable
1403
+ * @param <R>
1404
+ * the type emitted by the Observables emitted by <code>func</code>
1405
+ * @return an Observable that emits a sequence that is the result of applying the transformation
1406
+ * function to each item emitted by the source Observable and merging the results of
1407
+ * the Observables obtained from this transformation
1408
+ * @see {@link #mapMany(Observable, Func1)}
1409
+ */
1410
+ public static <T , R > Observable <R > flatMap (Observable <T > sequence , Func1 <T , Observable <R >> func ) {
1411
+ return mapMany (sequence , func );
1412
+ }
1413
+
1414
+ /**
1415
+ * Creates a new Observable sequence by applying a function that you supply to each object in the
1416
+ * original Observable sequence, where that function is itself an Observable that emits objects,
1417
+ * and then merges the results of that function applied to every item emitted by the original
1418
+ * Observable, emitting these merged results as its own sequence.
1419
+ * <p>
1420
+ * Note: mapMany and flatMap are equivalent.
1421
+ * <p>
1422
+ * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/mapMany.png">
1423
+ *
1424
+ * @param sequence
1425
+ * the source Observable
1426
+ * @param func
1427
+ * a function to apply to each item emitted by the source Observable, generating a
1428
+ * Observable
1429
+ * @param <T>
1430
+ * the type emitted by the source Observable
1431
+ * @param <R>
1432
+ * the type emitted by the Observables emitted by <code>func</code>
1433
+ * @return an Observable that emits a sequence that is the result of applying the transformation
1434
+ * function to each item emitted by the source Observable and merging the results of
1435
+ * the Observables obtained from this transformation
1436
+ * @see {@link #mapMany(Observable, Func1)}
1437
+ */
1438
+ public static <T , R > Observable <R > flatMap (Observable <T > sequence , final Object func ) {
1439
+ return mapMany (sequence , func );
1440
+ }
1441
+
1381
1442
/**
1382
1443
* Groups the elements of an observable and selects the resulting elements by using a specified function.
1383
1444
*
@@ -2032,6 +2093,19 @@ public Boolean call(T t, Integer integer)
2032
2093
}));
2033
2094
}
2034
2095
2096
+ /**
2097
+ * Return a Future representing a single value of the Observable.
2098
+ * <p>
2099
+ * 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>.
2100
+ *
2101
+ * @param that
2102
+ * the source Observable
2103
+ * @returna Future that expects a single item emitted by the source Observable
2104
+ */
2105
+ public static <T > Future <T > toFuture (final Observable <T > that ) {
2106
+ return OperationToFuture .toFuture (that );
2107
+ }
2108
+
2035
2109
/**
2036
2110
* Returns an Observable that emits a single item, a list composed of all the items emitted by
2037
2111
* the source Observable.
@@ -2115,11 +2189,15 @@ public static <T> Iterable<T> mostRecent(Observable<T> source, T initialValue) {
2115
2189
2116
2190
/**
2117
2191
* Returns a connectable observable sequence that upon connection causes the source sequence to push results into the specified subject.
2118
- *
2119
- * @param source the source sequence whose elements will be pushed into the specified subject.
2120
- * @param subject the subject to push source elements into.
2121
- * @param <T> source type
2122
- * @param <R> result type
2192
+ *
2193
+ * @param source
2194
+ * the source sequence whose elements will be pushed into the specified subject.
2195
+ * @param subject
2196
+ * the subject to push source elements into.
2197
+ * @param <T>
2198
+ * source type
2199
+ * @param <R>
2200
+ * result type
2123
2201
* @return a connectable observable sequence that upon connection causes the source sequence to push results into the specified subject.
2124
2202
*/
2125
2203
public static <T , R > ConnectableObservable <R > multicast (Observable <T > source , final Subject <T , R > subject ) {
@@ -2128,7 +2206,7 @@ public static <T, R> ConnectableObservable<R> multicast(Observable<T> source, fi
2128
2206
2129
2207
/**
2130
2208
* Returns the only element of an observable sequence and throws an exception if there is not exactly one element in the observable sequence.
2131
- *
2209
+ *
2132
2210
* @param that
2133
2211
* the source Observable
2134
2212
* @return The single element in the observable sequence.
@@ -2698,6 +2776,48 @@ public Boolean call(T t1) {
2698
2776
});
2699
2777
}
2700
2778
2779
+ /**
2780
+ * Creates a new Observable sequence by applying a function that you supply to each item in the
2781
+ * original Observable sequence, where that function is itself an Observable that emits items, and
2782
+ * then merges the results of that function applied to every item emitted by the original
2783
+ * Observable, emitting these merged results as its own sequence.
2784
+ * <p>
2785
+ * Note: mapMany and flatMap are equivalent.
2786
+ * <p>
2787
+ * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/mapMany.png">
2788
+ *
2789
+ * @param func
2790
+ * a function to apply to each item in the sequence, that returns an Observable.
2791
+ * @return an Observable that emits a sequence that is the result of applying the transformation
2792
+ * function to each item in the input sequence and merging the results of the
2793
+ * Observables obtained from this transformation.
2794
+ * @see {@link #mapMany(Func1)}
2795
+ */
2796
+ public <R > Observable <R > flatMap (Func1 <T , Observable <R >> func ) {
2797
+ return mapMany (func );
2798
+ }
2799
+
2800
+ /**
2801
+ * Creates a new Observable sequence by applying a function that you supply to each item in the
2802
+ * original Observable sequence, where that function is itself an Observable that emits items, and
2803
+ * then merges the results of that function applied to every item emitted by the original
2804
+ * Observable, emitting these merged results as its own sequence.
2805
+ * <p>
2806
+ * Note: mapMany and flatMap are equivalent.
2807
+ * <p>
2808
+ * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/mapMany.png">
2809
+ *
2810
+ * @param callback
2811
+ * a function to apply to each item in the sequence that returns an Observable.
2812
+ * @return an Observable that emits a sequence that is the result of applying the transformation'
2813
+ * function to each item in the input sequence and merging the results of the
2814
+ * Observables obtained from this transformation.
2815
+ * @see {@link #mapMany(Object)}
2816
+ */
2817
+ public <R > Observable <R > flatMap (final Object callback ) {
2818
+ return mapMany (callback );
2819
+ }
2820
+
2701
2821
/**
2702
2822
* Filters an Observable by discarding any of its emissions that do not meet some test.
2703
2823
* <p>
@@ -2834,13 +2954,16 @@ public R call(T t1) {
2834
2954
* then merges the results of that function applied to every item emitted by the original
2835
2955
* Observable, emitting these merged results as its own sequence.
2836
2956
* <p>
2957
+ * Note: mapMany and flatMap are equivalent.
2958
+ * <p>
2837
2959
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/mapMany.png">
2838
2960
*
2839
2961
* @param func
2840
2962
* a function to apply to each item in the sequence, that returns an Observable.
2841
2963
* @return an Observable that emits a sequence that is the result of applying the transformation
2842
2964
* function to each item in the input sequence and merging the results of the
2843
2965
* Observables obtained from this transformation.
2966
+ * @see {@link #flatMap(Func1)}
2844
2967
*/
2845
2968
public <R > Observable <R > mapMany (Func1 <T , Observable <R >> func ) {
2846
2969
return mapMany (this , func );
@@ -2852,13 +2975,16 @@ public <R> Observable<R> mapMany(Func1<T, Observable<R>> func) {
2852
2975
* then merges the results of that function applied to every item emitted by the original
2853
2976
* Observable, emitting these merged results as its own sequence.
2854
2977
* <p>
2978
+ * Note: mapMany and flatMap are equivalent.
2979
+ * <p>
2855
2980
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/mapMany.png">
2856
2981
*
2857
2982
* @param callback
2858
2983
* a function to apply to each item in the sequence that returns an Observable.
2859
2984
* @return an Observable that emits a sequence that is the result of applying the transformation'
2860
2985
* function to each item in the input sequence and merging the results of the
2861
2986
* Observables obtained from this transformation.
2987
+ * @see {@link #flatMap(Object))}
2862
2988
*/
2863
2989
public <R > Observable <R > mapMany (final Object callback ) {
2864
2990
@ SuppressWarnings ("rawtypes" )
@@ -3393,11 +3519,14 @@ public <E> Observable<T> takeUntil(Observable<E> other) {
3393
3519
}
3394
3520
3395
3521
/**
3396
- * Adds a timestamp to each item emitted by this observable.
3397
- * @return An observable sequence of timestamped items.
3522
+ * Return a Future representing a single value of the Observable.
3523
+ * <p>
3524
+ * 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>.
3525
+ *
3526
+ * @returna Future that expects a single item emitted by the source Observable
3398
3527
*/
3399
- public Observable < Timestamped < T >> timestamp () {
3400
- return create ( OperationTimestamp . timestamp ( this ) );
3528
+ public Future < T > toFuture () {
3529
+ return toFuture ( this );
3401
3530
}
3402
3531
3403
3532
/**
0 commit comments