Skip to content

Commit

Permalink
added where operation to Observable
Browse files Browse the repository at this point in the history
  • Loading branch information
prabirshrestha committed Mar 13, 2013
1 parent 6152588 commit 141a9f8
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions rxjava-core/src/main/java/rx/Observable.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import rx.operators.OperationDefer;
import rx.operators.OperationDematerialize;
import rx.operators.OperationFilter;
import rx.operators.OperationWhere;
import rx.operators.OperationMap;
import rx.operators.OperationMaterialize;
import rx.operators.OperationMerge;
Expand Down Expand Up @@ -722,6 +723,21 @@ public Boolean call(T t1) {
});
}

/**
* Filters an Observable by discarding any of its emissions that do not meet some test.
* <p>
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/filter.png">
*
* @param that
* the Observable to filter
* @param predicate
* a function that evaluates the items emitted by the source Observable, returning <code>true</code> if they pass the filter
* @return an Observable that emits only those items in the original Observable that the filter evaluates as true
*/
public static <T> Observable<T> where(Observable<T> that, Func1<T, Boolean> predicate) {
return _create(OperationWhere.where(that, predicate));
}

/**
* Converts an {@link Iterable} sequence to an Observable sequence.
*
Expand Down Expand Up @@ -2419,6 +2435,21 @@ public Boolean call(T t1) {
});
}

/**
* Filters an Observable by discarding any of its emissions that do not meet some test.
* <p>
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/filter.png">
*
* @param predicate
* a function that evaluates the items emitted by the source Observable, returning
* <code>true</code> if they pass the filter
* @return an Observable that emits only those items in the original Observable that the filter
* evaluates as <code>true</code>
*/
public Observable<T> where(Func1<T, Boolean> predicate) {
return where(this, predicate);
}

/**
* Returns the last element of an observable sequence with a specified source.
*
Expand Down

0 comments on commit 141a9f8

Please sign in to comment.