Skip to content

doOnDispose() vs doOnUnsubscribe() #4811

Closed
@julioromano

Description

@julioromano

While migrating some code from 1.2.x to 2.0 I've noticed a difference:

  • 1.2.x : Observable.doOnUnsubscribe() is always called whenever an observable chain terminates, either because it's been explicitly terminated with Subscription.unsubscribe() or because onComplete() or onError() have been called.
    This is the way I usually used to insert side effects on chain termination.

  • 2.x : there is no Observable.doOnUnsubscribe() so I've resorted using Observable.doOnDispose() instead but this one is called only when explicitly terminating an observable chain with Disposable.dispose();

I'm assuming this difference is intended (i.e. not a bug) so how can we 'insert' side effects on chain termination with RxJava 2.0?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions