@@ -2814,7 +2814,36 @@ public static <T> Observable<Boolean> sequenceEqual(Observable<? extends T> firs
2814
2814
* @see <a href="http://reactivex.io/documentation/operators/switch.html">ReactiveX operators documentation: Switch</a>
2815
2815
*/
2816
2816
public static <T> Observable<T> switchOnNext(Observable<? extends Observable<? extends T>> sequenceOfSequences) {
2817
- return sequenceOfSequences.lift(OperatorSwitch.<T>instance());
2817
+ return sequenceOfSequences.lift(OperatorSwitch.<T>instance(false));
2818
+ }
2819
+
2820
+ /**
2821
+ * Converts an Observable that emits Observables into an Observable that emits the items emitted by the
2822
+ * most recently emitted of those Observables and delays any exception until all Observables terminate.
2823
+ * <p>
2824
+ * <img width="640" height="370" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/switchDo.png" alt="">
2825
+ * <p>
2826
+ * {@code switchOnNext} subscribes to an Observable that emits Observables. Each time it observes one of
2827
+ * these emitted Observables, the Observable returned by {@code switchOnNext} begins emitting the items
2828
+ * emitted by that Observable. When a new Observable is emitted, {@code switchOnNext} stops emitting items
2829
+ * from the earlier-emitted Observable and begins emitting items from the new one.
2830
+ * <dl>
2831
+ * <dt><b>Scheduler:</b></dt>
2832
+ * <dd>{@code switchOnNext} does not operate by default on a particular {@link Scheduler}.</dd>
2833
+ * </dl>
2834
+ *
2835
+ * @param <T> the item type
2836
+ * @param sequenceOfSequences
2837
+ * the source Observable that emits Observables
2838
+ * @return an Observable that emits the items emitted by the Observable most recently emitted by the source
2839
+ * Observable
2840
+ * @see <a href="http://reactivex.io/documentation/operators/switch.html">ReactiveX operators documentation: Switch</a>
2841
+ * @Experimental The behavior of this can change at any time.
2842
+ * @since (if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
2843
+ */
2844
+ @Experimental
2845
+ public static <T> Observable<T> switchOnNextDelayError(Observable<? extends Observable<? extends T>> sequenceOfSequences) {
2846
+ return sequenceOfSequences.lift(OperatorSwitch.<T>instance(true));
2818
2847
}
2819
2848
2820
2849
/**
@@ -8637,6 +8666,30 @@ public final <R> Observable<R> switchMap(Func1<? super T, ? extends Observable<?
8637
8666
return switchOnNext(map(func));
8638
8667
}
8639
8668
8669
+ /**
8670
+ * Returns a new Observable by applying a function that you supply to each item emitted by the source
8671
+ * Observable that returns an Observable, and then emitting the items emitted by the most recently emitted
8672
+ * of these Observables and delays any error until all Observables terminate.
8673
+ * <p>
8674
+ * <img width="640" height="350" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/switchMap.png" alt="">
8675
+ * <dl>
8676
+ * <dt><b>Scheduler:</b></dt>
8677
+ * <dd>{@code switchMap} does not operate by default on a particular {@link Scheduler}.</dd>
8678
+ * </dl>
8679
+ *
8680
+ * @param func
8681
+ * a function that, when applied to an item emitted by the source Observable, returns an
8682
+ * Observable
8683
+ * @return an Observable that emits the items emitted by the Observable returned from applying {@code func} to the most recently emitted item emitted by the source Observable
8684
+ * @see <a href="http://reactivex.io/documentation/operators/flatmap.html">ReactiveX operators documentation: FlatMap</a>
8685
+ * @Experimental The behavior of this can change at any time.
8686
+ * @since (if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
8687
+ */
8688
+ @Experimental
8689
+ public final <R> Observable<R> switchMapDelayError(Func1<? super T, ? extends Observable<? extends R>> func) {
8690
+ return switchOnNextDelayError(map(func));
8691
+ }
8692
+
8640
8693
/**
8641
8694
* Returns an Observable that emits only the first {@code count} items emitted by the source Observable. If the source emits fewer than
8642
8695
* {@code count} items then all of its items are emitted.
0 commit comments