Skip to content

Commit 4bfd6a4

Browse files
SwitchDo
- remove instance method - rename to switchOnNext (leaving behind deprecated switchDo for now) See ReactiveX#342
1 parent bd0e5c7 commit 4bfd6a4

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -783,29 +783,28 @@ public static <T> Observable<T> never() {
783783
* the source Observable that emits Observables
784784
* @return an Observable that emits only the items emitted by the most recently published
785785
* Observable
786+
* @deprecated Being renamed to {@link #switchOnNext}
786787
*/
788+
@Deprecated
787789
public static <T> Observable<T> switchDo(Observable<? extends Observable<? extends T>> sequenceOfSequences) {
788-
// TODO should this static remain? I have left it because it is an Observable<Observable>
789790
return create(OperationSwitch.switchDo(sequenceOfSequences));
790791
}
791792

792793
/**
793-
* On an Observable that emits Observables, creates a single Observable that
794+
* Given an Observable that emits Observables, creates a single Observable that
794795
* emits the items emitted by the most recently published of those Observables.
795796
* <p>
796797
* <img width="640" src="https://github.com/Netflix/RxJava/wiki/images/rx-operators/switchDo.png">
797798
*
799+
* @param sequenceOfSequences
800+
* the source Observable that emits Observables
798801
* @return an Observable that emits only the items emitted by the most recently published
799802
* Observable
800-
* @throws ClassCastException
801-
* if sequence not of type {@code Observable<Observable<T>}
802803
*/
803-
@SuppressWarnings("unchecked")
804-
public Observable<T> switchDo() {
805-
// TODO can we come up with a better name than this? It should be 'switch' but that is reserved.
806-
// Perhaps 'switchOnNext'?
807-
return create(OperationSwitch.switchDo((Observable<? extends Observable<? extends T>>) this));
804+
public static <T> Observable<T> switchOnNext(Observable<? extends Observable<? extends T>> sequenceOfSequences) {
805+
return create(OperationSwitch.switchDo(sequenceOfSequences));
808806
}
807+
809808

810809
/**
811810
* Accepts an Observable and wraps it in another Observable that ensures that the resulting

0 commit comments

Comments
 (0)