-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Observable.using() disposes resource before upstream #6347
Comments
Indeed eagerness is not affecting the dispose order, and I'm not certain if it should or not. /cc @artem-zinnatullin @davidmoten @vanniktech The shortest workaround would be for you to take the operator by source and have a local version with the desired order of disposal. |
I'm not sure either. Haven't really used |
My understanding was that resource is allocated firtst and free'd last, and i used it in Android to wrap some of APIs, like 'call register/start', 'handle results as observable', 'call unregister/stop'. But as on dispose Using first disposes resource (in my case - calls 'unregister/stop') it ended up in some kind of 'race conditon': observable chain is partially disposed, 'stop' is called, but as stop can be called by Android itself - it emits onError, which is not handled already, thus app crashes with undeliverable exception. Currently i've went around this by copying code from Using and making it always dispose resource last, as was suggested. |
This would be a change for 2.x with unexpected consequences so instead, this should be changed in 3.x. |
Closing via #6534. |
I've expected that Observable.using flow is:
But for me actual is sometimes
As I understand, using 'eager' makes second flow consistent,but i need first behavior, which is not observed on dispose() call - resource is disposed first always, then observable. What is correct way to make Observable which is not eager even on dispose?
RxJava/src/main/java/io/reactivex/internal/operators/observable/ObservableUsing.java
Line 151 in 5278124
The text was updated successfully, but these errors were encountered: