本文整理了Java中rx.Observable.contains()
方法的一些代码示例,展示了Observable.contains()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Observable.contains()
方法的具体详情如下:
包路径:rx.Observable
类名称:Observable
方法名:contains
[英]Returns an Observable that emits a Boolean that indicates whether the source Observable emitted a specified item.
Scheduler: contains does not operate by default on a particular Scheduler.
[中]返回发出布尔值的可观察对象,该布尔值指示源可观察对象是否发出指定项。
调度程序:默认情况下,contains不会在特定调度程序上运行。
代码示例来源:origin: henrymorgen/android-advanced-light
private void contains() {
Observable.just(1,2,3).contains(1).subscribe(new Action1<Boolean>() {
@Override
public void call(Boolean aBoolean) {
Log.d(TAG, "contains:"+aBoolean);
}
});
}
代码示例来源:origin: leeowenowen/rxjava-examples
@Override
public void run() {
Observable.range(1, 10).contains(3).subscribe(new Action1<Boolean>() {
@Override
public void call(Boolean aBoolean) {
log(aBoolean);
}
});
}
});
代码示例来源:origin: nurkiewicz/rxjava-book-examples
@Test
public void sample_550() throws Exception {
Observable<Integer> numbers = Observable.range(1, 5);
numbers.all(x -> x != 4); // [false]
numbers.exists(x -> x == 4); // [true]
numbers.contains(4); // [true]
}
代码示例来源:origin: vert-x3/vertx-rx
protected Completable rxAssertAutoCommit(SQLConnection conn) {
String testName = UUID.randomUUID().toString();
return conn.rxExecute(String.format(INSERT_FOLK_SQL, testName)).toCompletable()
.andThen(client.rxGetConnection().flatMapCompletable(other -> {
return uniqueNames(other).contains(testName).toSingle()
.flatMapCompletable(contains -> {
if (contains) {
return Completable.complete();
}
return Completable.error(new AssertionError("Connection should be back in autocommit mode"));
})
.doAfterTerminate(other::close);
}));
}
内容来源于网络,如有侵权,请联系作者删除!