RxJava - .doAfterSubscribe()? [英] RxJava - .doAfterSubscribe()?
本文介绍了RxJava - .doAfterSubscribe()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
.doOnSubscribe()
在 observable 的订阅者被附加之前执行.
.doOnSubscribe()
is executed before an observable’s subscriber is attached.
我需要在附加订阅者之后 执行副作用.这可能吗?
I need to execute a side effect after the subscriber is attached. Is this possible?
推荐答案
在真正的工作"之前使用流的组合来执行一些事情:
Use composition of flows to perform something before the "real work":
Observable source = ... // the actual flow
source.startWith(
Observable.empty()
.doOnCompleted(() -> { /* your initial side-effect here */ })
)
.subscribe(/* consume the events of source */);
这篇关于RxJava - .doAfterSubscribe()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文