Skip to content

switchDo to switchOnNext #348

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 5, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions rxjava-core/src/main/java/rx/Observable.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public static interface OnSubscribeFunc<T> extends Function {
/**
* Observable with Function to execute when subscribed to.
* <p>
* NOTE: Use {@link #create(Func1)} to create an Observable instead of this method unless you
* NOTE: Use {@link #create(OnSubscribeFunc)} to create an Observable instead of this constructor unless you
* specifically have a need for inheritance.
*
* @param onSubscribe
Expand Down Expand Up @@ -783,29 +783,28 @@ public static <T> Observable<T> never() {
* the source Observable that emits Observables
* @return an Observable that emits only the items emitted by the most recently published
* Observable
* @deprecated Being renamed to {@link #switchOnNext}
*/
@Deprecated
public static <T> Observable<T> switchDo(Observable<? extends Observable<? extends T>> sequenceOfSequences) {
// TODO should this static remain? I have left it because it is an Observable<Observable>
return create(OperationSwitch.switchDo(sequenceOfSequences));
}

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


/**
* Accepts an Observable and wraps it in another Observable that ensures that the resulting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private Subscription protectivelyWrapAndSubscribe(Observer<? super T> observer)
* <p>
* NOTE: This will block even if the Observable is asynchronous.
* <p>
* This is similar to {@link #subscribe(Observer)}, but it blocks. Because it blocks it does
* This is similar to {@link Observable#subscribe(Observer)}, but it blocks. Because it blocks it does
* not need the {@link Observer#onCompleted()} or {@link Observer#onError(Throwable)} methods.
* <p>
* <img width="640" src="https://github.com/Netflix/RxJava/wiki/images/rx-operators/B.forEach.png">
Expand Down