Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canceling an Observable in RxJava 2.x #5944

Closed
akoshman opened this issue Apr 1, 2018 · 4 comments
Closed

Canceling an Observable in RxJava 2.x #5944

akoshman opened this issue Apr 1, 2018 · 4 comments

Comments

@akoshman
Copy link

akoshman commented Apr 1, 2018

Observable.fromFuture's javadoc says "Unlike 1.x, cancelling the Observable won't cancel the future. If necessary, one can use composition to achieve the cancellation effect: futureObservableSource.doOnCancel(() -> future.cancel(true));."

Flowable has this method and it works as expected like this:

    Disposable disposable = Flowable.fromFuture(response, Schedulers.io())
      .doOnCancel(() -> response.cancel(true))
      .subscribe();

But Observable seems to lack doOnCancel method, doesn't it?
Tested RxJava's version is 2.1.10.

@akarnokd
Copy link
Member

akarnokd commented Apr 1, 2018

Its equivalent is doOnDispose. A copy-paste error. PR welcome.

@RomanWuattier
Copy link
Contributor

Hello,
Does someone work on this topic? I would like to start contributing, can I do it?

@akarnokd
Copy link
Member

akarnokd commented Apr 2, 2018

@RomanWuattier You can start working on this.

RomanWuattier added a commit to RomanWuattier/RxJava that referenced this issue Apr 2, 2018
* Replace `doOnCancel` by `doOnDispose`
akarnokd pushed a commit that referenced this issue Apr 3, 2018
* Replace `doOnCancel` by `doOnDispose`
@akarnokd
Copy link
Member

Closing via #5948.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants