io.reactivex.Single.to()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(1.9k)|赞(0)|评价(0)|浏览(160)

本文整理了Java中io.reactivex.Single.to()方法的一些代码示例,展示了Single.to()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Single.to()方法的具体详情如下:
包路径:io.reactivex.Single
类名称:Single
方法名:to

Single.to介绍

[英]Calls the specified converter function with the current Single instance during assembly time and returns its result. Scheduler: to does not operate by default on a particular Scheduler.
[中]在汇编期间使用当前单个实例调用指定的转换器函数,并返回其结果。调度程序:默认情况下,不在特定调度程序上运行。

代码示例

代码示例来源:origin: ReactiveX/RxJava

@Test(expected = NullPointerException.class)
public void toNull() {
  just1.to(null);
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void to() {
  assertEquals(1, Single.just(1).to(new Function<Single<Integer>, Integer>() {
    @Override
    public Integer apply(Single<Integer> v) throws Exception {
      return 1;
    }
  }).intValue());
}

代码示例来源:origin: akarnokd/RxJava2Jdk8Interop

@Test(expected = IllegalArgumentException.class)
  public void toStreamError() {
    Single.<Integer>error(new IllegalArgumentException())
    .to(SingleInterop.toStream())
    .collect(Collectors.toList());
  }
}

代码示例来源:origin: akarnokd/RxJava2Jdk8Interop

@Test
public void toStream() {
  List<Integer> list = Single.just(1)
  .to(SingleInterop.toStream())
  .collect(Collectors.toList());
  Assert.assertEquals(Arrays.asList(1), list);
}

代码示例来源:origin: TrustWallet/trust-wallet-android-source

public Single<Wallet> find() {
    return walletRepository
        .getDefaultWallet()
        .onErrorResumeNext(walletRepository
            .fetchWallets()
            .to(single -> Flowable.fromArray(single.blockingGet()))
            .firstOrError()
            .flatMapCompletable(walletRepository::setDefaultWallet)
            .andThen(walletRepository.getDefaultWallet()))
        .observeOn(AndroidSchedulers.mainThread());
  }
}

代码示例来源:origin: akarnokd/RxJava2Jdk8Interop

@Test(expected = IllegalArgumentException.class)
public void getError() {
  TestHelper.assertFuture(null, Single.error(new IllegalArgumentException())
  .to(SingleInterop.get()));
}

代码示例来源:origin: akarnokd/RxJava2Jdk8Interop

@Test
public void get() {
  TestHelper.assertFuture(1, Single.just(1)
  .to(SingleInterop.get()));
}

相关文章

微信公众号

最新文章

更多