@@ -3653,7 +3653,7 @@ public Observable<Observable<T>> window(long timespan, long timeshift, TimeUnit
3653
3653
* @see <a href="https://github.com/Netflix/RxJava/wiki/Combining-Observables#zip">RxJava Wiki: zip()</a>
3654
3654
*/
3655
3655
public static <R > Observable <R > zip (Observable <? extends Observable <?>> ws , final FuncN <? extends R > zipFunction ) {
3656
- return ws .toList ().mapMany (new Func1 <List <? extends Observable <?>>, Observable <? extends R >>() {
3656
+ return ws .toList ().mergeMap (new Func1 <List <? extends Observable <?>>, Observable <? extends R >>() {
3657
3657
@ Override
3658
3658
public Observable <R > call (List <? extends Observable <?>> wsList ) {
3659
3659
return create (OperationZip .zip (wsList , zipFunction ));
@@ -3891,7 +3891,64 @@ public Observable<T> finallyDo(Action0 action) {
3891
3891
* @see #mapMany(Func1)
3892
3892
*/
3893
3893
public <R > Observable <R > flatMap (Func1 <? super T , ? extends Observable <? extends R >> func ) {
3894
- return mapMany (func );
3894
+ return mergeMap (func );
3895
+ }
3896
+
3897
+ /**
3898
+ * Creates a new Observable by applying a function that you supply to each
3899
+ * item emitted by the source Observable, where that function returns an
3900
+ * Observable, and then merging those resulting Observables and emitting the
3901
+ * results of this merger.
3902
+ * <p>
3903
+ * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/flatMap.png">
3904
+ * <p>
3905
+ * Note: {@code mapMany} and {@code flatMap} are equivalent.
3906
+ *
3907
+ * @param func a function that, when applied to an item emitted by the
3908
+ * source Observable, returns an Observable
3909
+ * @return an Observable that emits the result of applying the
3910
+ * transformation function to each item emitted by the source
3911
+ * Observable and merging the results of the Observables obtained
3912
+ * from this transformation.
3913
+ * @see <a href="https://github.com/Netflix/RxJava/wiki/Transforming-Observables#mapmany-or-flatmap-and-mapmanydelayerror">RxJava Wiki: flatMap()</a>
3914
+ * @see #flatMap(Func1)
3915
+ */
3916
+ public <R > Observable <R > mergeMap (Func1 <? super T , ? extends Observable <? extends R >> func ) {
3917
+ return merge (map (func ));
3918
+ }
3919
+
3920
+ /**
3921
+ * Creates a new Observable by applying a function that you supply to each
3922
+ * item emitted by the source Observable, where that function returns an
3923
+ * Observable, and then concatting those resulting Observables and emitting the
3924
+ * results of this concat.
3925
+ * <p>
3926
+ *
3927
+ * @param func a function that, when applied to an item emitted by the
3928
+ * source Observable, returns an Observable
3929
+ * @return an Observable that emits the result of applying the
3930
+ * transformation function to each item emitted by the source
3931
+ * Observable and concatting the results of the Observables obtained
3932
+ * from this transformation.
3933
+ */
3934
+ public <R > Observable <R > concatMap (Func1 <? super T , ? extends Observable <? extends R >> func ) {
3935
+ return concat (map (func ));
3936
+ }
3937
+
3938
+ /**
3939
+ * Creates a new Observable by applying a function that you supply to each
3940
+ * item emitted by the source Observable resulting in an Observable of Observables.
3941
+ * <p>
3942
+ * Then a {@link #switchLatest(Observable)} / {@link #switchOnNext(Observable)} is applied.
3943
+ *
3944
+ * @param func a function that, when applied to an item emitted by the
3945
+ * source Observable, returns an Observable
3946
+ * @return an Observable that emits the result of applying the
3947
+ * transformation function to each item emitted by the source
3948
+ * Observable and then switch
3949
+ */
3950
+ public <R > Observable <R > switchMap (Func1 <? super T , ? extends Observable <? extends R >> func ) {
3951
+ return switchOnNext (map (func ));
3895
3952
}
3896
3953
3897
3954
/**
@@ -3965,9 +4022,10 @@ public <R> Observable<R> mapWithIndex(Func2<? super T, Integer, ? extends R> fun
3965
4022
* from this transformation.
3966
4023
* @see <a href="https://github.com/Netflix/RxJava/wiki/Transforming-Observables#mapmany-or-flatmap-and-mapmanydelayerror">RxJava Wiki: mapMany()</a>
3967
4024
* @see #flatMap(Func1)
4025
+ * @deprecated
3968
4026
*/
3969
4027
public <R > Observable <R > mapMany (Func1 <? super T , ? extends Observable <? extends R >> func ) {
3970
- return create ( OperationMap . mapMany ( this , func ) );
4028
+ return mergeMap ( func );
3971
4029
}
3972
4030
3973
4031
/**
0 commit comments