Skip to content

Commit

Permalink
Merge pull request ReactiveX#259 from michaeldejong/operation-switch
Browse files Browse the repository at this point in the history
Added the switch operator to Observable
  • Loading branch information
benjchristensen committed May 16, 2013
2 parents d5678e0 + b40feb2 commit cf243ee
Show file tree
Hide file tree
Showing 2 changed files with 422 additions and 0 deletions.
14 changes: 14 additions & 0 deletions rxjava-core/src/main/java/rx/Observable.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import rx.operators.OperationScan;
import rx.operators.OperationSkip;
import rx.operators.OperationSubscribeOn;
import rx.operators.OperationSwitch;
import rx.operators.OperationSynchronize;
import rx.operators.OperationTake;
import rx.operators.OperationTakeLast;
Expand Down Expand Up @@ -1800,6 +1801,19 @@ public static <T> Observable<T> skip(final Observable<T> items, int num) {
return create(OperationSkip.skip(items, num));
}

/**
* Accepts an {@link Observable} sequence of {@link Observable} sequences, and transforms it into a single
* {@link Observable} sequence, which publishes the values of the most recently published {@link Observable} sequence.
*
* @param sequenceOfSequences
* the {@link Observable} sequence of {@link Observable} sequences.
* @return an {@link Observable} which publishes only the values of the most recently published
* {@link Observable} sequence.
*/
public static <T> Observable<T> switchDo(Observable<Observable<T>> sequenceOfSequences) {
return create(OperationSwitch.switchDo(sequenceOfSequences));
}

/**
* Accepts an Observable and wraps it in another Observable that ensures that the resulting
* Observable is chronologically well-behaved.
Expand Down
Loading

0 comments on commit cf243ee

Please sign in to comment.