Skip to content

Commit 67d8ac7

Browse files
Merge pull request #348 from benjchristensen/switchOnNext
switchDo to switchOnNext
2 parents e0da522 + 4149aad commit 67d8ac7

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public static interface OnSubscribeFunc<T> extends Function {
127127
/**
128128
* Observable with Function to execute when subscribed to.
129129
* <p>
130-
* NOTE: Use {@link #create(Func1)} to create an Observable instead of this method unless you
130+
* NOTE: Use {@link #create(OnSubscribeFunc)} to create an Observable instead of this constructor unless you
131131
* specifically have a need for inheritance.
132132
*
133133
* @param onSubscribe
@@ -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

rxjava-core/src/main/java/rx/observables/BlockingObservable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ private Subscription protectivelyWrapAndSubscribe(Observer<? super T> observer)
109109
* <p>
110110
* NOTE: This will block even if the Observable is asynchronous.
111111
* <p>
112-
* This is similar to {@link #subscribe(Observer)}, but it blocks. Because it blocks it does
112+
* This is similar to {@link Observable#subscribe(Observer)}, but it blocks. Because it blocks it does
113113
* not need the {@link Observer#onCompleted()} or {@link Observer#onError(Throwable)} methods.
114114
* <p>
115115
* <img width="640" src="https://github.com/Netflix/RxJava/wiki/images/rx-operators/B.forEach.png">

0 commit comments

Comments
 (0)