https://kotlinlang.org logo
#rx
Title
# rx
o

ossama

01/26/2020, 3:53 PM
Hi all, is it possible to convert a Completable to an Observable? I am calling
toObservable()
on my completable, but nothing is emitted in onNext. The doc of the method
Completable.toObservable()
says:
Copy code
Returns an Observable which when subscribed to subscribes to this Completable and relays the terminal events to the subscriber.
I am using something like this
Copy code
Completable.complete()
    .toObservable<Any>()
    .subscribe { }
z

Zach Klippenstein (he/him) [MOD]

01/26/2020, 4:29 PM
A Completable doesn't emit any items, just terminal events, so when you convert to an Observable the observable will do the same. If you want to emit some value on completion, use an operator like
andThen
o

ossama

01/26/2020, 4:54 PM
Many thanks @Zach Klippenstein (he/him) [MOD]. That’s exactly what I was looking for 👍
2 Views