本文整理了Java中io.reactivex.Single.fromFuture()
方法的一些代码示例,展示了Single.fromFuture()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Single.fromFuture()
方法的具体详情如下:
包路径:io.reactivex.Single
类名称:Single
方法名:fromFuture
[英]Converts a Future into a Single.
You can convert any object that supports the Future interface into a Single that emits the return value of the Future#get method of that object, by passing the object into the frommethod.
Important note: This Single is blocking; you cannot dispose it. Scheduler: fromFuture does not operate by default on a particular Scheduler.
[中]将未来转化为单一的。
通过将对象传递到frommethod,可以将支持Future接口的任何对象转换为发出该对象的Future#get方法返回值的单个对象。
*重要提示:*此单曲为阻塞;你不能处理它。调度程序:默认情况下,fromFuture不会在特定调度程序上运行。
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void fromFutureTimedSchedulerNull() {
Single.fromFuture(new FutureTask<Object>(new Callable<Object>() {
@Override
public Object call() throws Exception {
return null;
}
}), 1, TimeUnit.SECONDS, null);
}
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void fromFutureTimedUnitNull() {
Single.fromFuture(new FutureTask<Object>(new Callable<Object>() {
@Override
public Object call() throws Exception {
return null;
}
}), 1, null);
}
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void fromFutureSchedulerNull() {
Single.fromFuture(new FutureTask<Object>(new Callable<Object>() {
@Override
public Object call() throws Exception {
return null;
}
}), null);
}
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void fromFutureNull() {
Single.fromFuture((Future<Integer>)null);
}
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void fromFutureTimedFutureNull() {
Single.fromFuture(null, 1, TimeUnit.SECONDS);
}
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void fromFutureReturnsNull() {
FutureTask<Object> f = new FutureTask<Object>(Functions.EMPTY_RUNNABLE, null);
f.run();
Single.fromFuture(f).blockingGet();
}
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void fromFutureTimedReturnsNull() {
FutureTask<Object> f = new FutureTask<Object>(Functions.EMPTY_RUNNABLE, null);
f.run();
Single.fromFuture(f, 1, TimeUnit.SECONDS).blockingGet();
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void fromFuture() throws Exception {
Single.fromFuture(Flowable.just(1).toFuture(), Schedulers.io())
.test()
.awaitDone(5, TimeUnit.SECONDS)
.assertResult(1);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void fromFutureTimeout() throws Exception {
Single.fromFuture(Flowable.never().toFuture(), 1, TimeUnit.SECONDS, Schedulers.io())
.test()
.awaitDone(5, TimeUnit.SECONDS)
.assertFailure(TimeoutException.class);
}
代码示例来源:origin: resteasy/Resteasy
@Override
public Single<?> fromCompletionStage(CompletionStage<?> completionStage)
{
return Single.fromFuture(completionStage.toCompletableFuture());
}
}
代码示例来源:origin: org.jboss.resteasy/resteasy-rxjava2
@Override
public Single<?> fromCompletionStage(CompletionStage<?> completionStage)
{
return Single.fromFuture(completionStage.toCompletableFuture());
}
}
代码示例来源:origin: yongjhih/rxfirebase
@Nonnull
@CheckReturnValue
public static Single<String> runTransaction(@Nonnull final FirebaseAuth firebaseAuth, @Nonnull final String uid) {
return Single.fromFuture(firebaseAuth.createCustomTokenAsync(uid));
}
代码示例来源:origin: yongjhih/rxfirebase
@Nonnull
@CheckReturnValue
public static <T> Single<T> runTransaction(@Nonnull final Firestore firestore, @Nonnull final Transaction.Function<T> updateFunction) {
return Single.fromFuture(firestore.runTransaction(updateFunction));
}
代码示例来源:origin: yongjhih/rxfirebase
@Nonnull
@CheckReturnValue
public static Single<List<DocumentSnapshot>> getAll(@Nonnull final Firestore firestore, final DocumentReference... documentReferences) {
return Single.fromFuture(firestore.getAll(documentReferences));
}
代码示例来源:origin: apache/cxf
@GET
@Produces("application/json")
@Path("textJsonSingle")
public Single<HelloWorldBean> getJsonSingle() {
CompletableFuture<HelloWorldBean> completableFuture = CompletableFuture
.supplyAsync(() -> {
sleep();
return new HelloWorldBean("Hello");
});
return Single.fromFuture(completableFuture);
}
代码示例来源:origin: akarnokd/akarnokd-misc
.fromFuture(httpRequest.executeAsync(myExecutor))
.map(httpResponse -> {
InputStreamReader inputStreamReader =
内容来源于网络,如有侵权,请联系作者删除!