I have Observable stream, and I want to convert it to Completable, how I could do that?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
The fluent way is to use Observable.ignoreElements()
.
Observable.just(1, 2, 3)
.ignoreElements()
Convert it back via toObservable
if needed.
回答2:
You can do something like below.
Observable<Integer> observable = Observable.just(1, 2, 3);
Completable completable = Completable.fromObservable(observable);
Like on an Observable, you will have to subscribe to the completable
to start the asynchronous process that Observable
wraps.
More details can be found here in the Java doc for the method.
回答3:
Use Completable.merge(YourObservable()...
回答4:
You could use Completable.fromObservable(xx). That is worked fine on my project.