Michał K Michał K -4 years ago 174
Android Question

Observable.just() which returns Unit in Kotlin

I have a piece of Observable which in the end either returns an error and retries or just returns onNext. I don't need anything in onNext, so this is just an


Now the problem is that at the end of the chain I have to hit this onNext and I don't have anything other than good old
. But I cannot return Observable.just(null) because it returns
, not
. I cannot return
, because it's not instantiable. Therefore I have
. It works, but looks ugly. Any idea for a better solution?

Answer Source

Use Observable.just(Unit). Unit itself is the single object of the type Unit.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download