rx-java - 为什么要使用 RxJava 中的新功能 Single?

标签 rx-java

文档非常清楚地说明了 Observable 的替代方案的作用:

The Single class implements the Reactive Pattern for a single value response. See Observable for the implementation of the Reactive Pattern for a stream or vector of values. Single behaves the same as Observable except that it can only emit either a single successful value or an error (there is no "onComplete" notification as there is for Observable) Like an Observable, a Single is lazy, can be either "hot" or "cold", synchronous or asynchronous.

但我看不出它有时可能比 Observable 更简单的原因,在哪里以及为什么使用它?

最佳答案

在某些情况下,可观察对象仅返回单个项目并结束(或错误)是有意义的。 This blog post简单地解释一下。

关于rx-java - 为什么要使用 RxJava 中的新功能 Single?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36152475/

相关文章:

java - 在这个简单的 RxJava 异步场景中我真的需要异常处理吗?

android - RxJava mixLatest - 可从更改中观察到

android - Single.defer() 未执行

rx-java - 我可以创建一个 Kotlin 扩展方法来将 rxJava 订阅添加到 CompositeSubscription 吗?

rx-java - SkipUntil 无法按预期工作

java - RXJava 忽略错误并在链中继续

android - 如何在 rxJava 中手动调用 observer.onNext

rx-java - 在同一线程中运行多个流

android - 将无限次调用的回调转换为 Observable

asynchronous - rxjava合并不同类型的可观察量