RxJava:单个阻塞与首先阻塞

Vir*_*dra 5 rx-java reactive

blockingSingle我永远无法理解 RxJava 中和blockingFirston之间的区别Observables。任何帮助将不胜感激。

eha*_*nom 8

来自https://github.com/ReactiveX/RxJava/wiki/Blocking-Observable-Operators的定义

\n\n
first() \xe2\x80\x94 block until the Observable emits an item, then return the first item \nemitted by the Observable\n\nsingle(\xe2\x80\x89) \xe2\x80\x94 if the Observable completes after emitting a single item, return \nthat item, otherwise throw an exception\n
Run Code Online (Sandbox Code Playgroud)\n\n

听起来像是first()在发出任何项目后立即返回,并single()等待 Observable 完成返回。

\n