Skip to content

Commit

Permalink
Merge pull request #348 from benjchristensen/switchOnNext
Browse files Browse the repository at this point in the history
switchDo to switchOnNext
  • Loading branch information
benjchristensen committed Sep 5, 2013
2 parents e0da522 + 4149aad commit 67d8ac7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
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

0 comments on commit 67d8ac7

Please sign in to comment.