I'm sure I read somewhere that .isDisposed()
is not guaranteed to return true
unless .dispose()
has been explicitly called. But this answer says that it always returns true
after .onComplete()
has been called, while this one says that .doOnDispose()
is never called after a completion event.
I'd like to create an Action
that runs if the Observable
is disposed, but not if it completes normally. Is there any way to guarantee this? What is the official answer on the semantics of .isDisposed()
? The possibility that it might or might not return true
after completion isn't very satisfactory.
Update: I'm trying to convert a Single
into a 1-item Observable
. Once it emits its item, it will of course become completed. But I would still like its .dispose()
method to trigger a separate action:
mObservable = mSingle
.toObservable()
.doOnDispose( () -> {
do stuff} );
The whole reason I am converting the Single
to an Observable
is to have the ability to handle the doOnDispose()
action. Am I correct that a Single
is torn down after emitting its item, so therefore its doOnDispose
method is no longer available? (If I'm wrong about this I can skip the conversion to an Observable
)