-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Observable.using() diposeEagerly clarification. #4144
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
Comments
This is correct.
Yes. Remember that a termination event will trigger |
Using the example code:
in RxJava < 1.1.6, the output is the following:
whereas the output for 1.1.6 is:
The primary difference being that the The use case for this is where a resource (created by Is this a misuse of |
The latter behavior is the correct one and is the result of the bugfix in #3922. If the generated |
I see. So in this specific case, if I wanted to delay the
or alternatively:
It seems a little sketchy, but appears to achieve the desired behaviour |
From my understanding, if
disposeEagerly == false
when callingObservable.using(resourceFactory, observableFactory, diposeEagerly)
, then thedisposeAction
should not be called when a termination event occurs.However, based on:
RxJava/src/main/java/rx/internal/operators/OnSubscribeUsing.java
Line 89 in d66d931
it appears that it just changes whether or not
disposeAction
is called before or after the termination event.Is my understanding correct? And if so, is this the desired behaviour? The documentation for
Observable.using(resourceFactory, observableFactory)
implies thatdisposeAction
is is only called on unsubscribe.The text was updated successfully, but these errors were encountered: