Skip to content

Commit 5191c30

Browse files
committed
Updated Observable API
1 parent f1399e6 commit 5191c30

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

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

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.mockito.MockitoAnnotations;
3737

3838
import rx.observables.GroupedObservable;
39+
import rx.operators.OperationAll;
3940
import rx.operators.OperationConcat;
4041
import rx.operators.OperationDefer;
4142
import rx.operators.OperationDematerialize;
@@ -1665,6 +1666,35 @@ public T call(T t1, T t2) {
16651666
});
16661667
}
16671668

1669+
/**
1670+
* Determines whether all elements of an observable sequence satisfies a condition.
1671+
* @param sequence an observable sequence whose elements to apply the predicate to.
1672+
* @param predicate a function to test each element for a condition.
1673+
* @param <T> the type of observable.
1674+
* @return true if all elements of an observable sequence satisfies a condition; otherwise, false.
1675+
*/
1676+
public static <T> Observable<Boolean> all(final Observable<T> sequence, final Func1<T, Boolean> predicate) {
1677+
return _create(OperationAll.all(sequence, predicate));
1678+
}
1679+
1680+
/**
1681+
* Determines whether all elements of an observable sequence satisfies a condition.
1682+
* @param sequence an observable sequence whose elements to apply the predicate to.
1683+
* @param predicate a function to test each element for a condition.
1684+
* @param <T> the type of observable.
1685+
* @return true if all elements of an observable sequence satisfies a condition; otherwise, false.
1686+
*/
1687+
public static <T> Observable<Boolean> all(final Observable<T> sequence, Object predicate) {
1688+
final FuncN _f = Functions.from(predicate);
1689+
1690+
return all(sequence, new Func1<T, Boolean>() {
1691+
@Override
1692+
public Boolean call(T t) {
1693+
return (Boolean) _f.call(t);
1694+
}
1695+
});
1696+
}
1697+
16681698
/**
16691699
* Returns an Observable that skips the first <code>num</code> items emitted by the source
16701700
* Observable. You can ignore the first <code>num</code> items emitted by an Observable and attend
@@ -2973,6 +3003,24 @@ public Observable<T> scan(final T initialValue, final Object accumulator) {
29733003
return scan(this, initialValue, accumulator);
29743004
}
29753005

3006+
/**
3007+
* Determines whether all elements of an observable sequence satisfies a condition.
3008+
* @param predicate a function to test each element for a condition.
3009+
* @return true if all elements of an observable sequence satisfies a condition; otherwise, false.
3010+
*/
3011+
public Observable<Boolean> all(Func1<T, Boolean> predicate) {
3012+
return all(this, predicate);
3013+
}
3014+
3015+
/**
3016+
* Determines whether all elements of an observable sequence satisfies a condition.
3017+
* @param predicate a function to test each element for a condition.
3018+
* @return true if all elements of an observable sequence satisfies a condition; otherwise, false.
3019+
*/
3020+
public Observable<Boolean> all(Object predicate) {
3021+
return all(this, predicate);
3022+
}
3023+
29763024
/**
29773025
* Returns an Observable that skips the first <code>num</code> items emitted by the source
29783026
* Observable.

0 commit comments

Comments
 (0)