-
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
3.x: Add subscribe with disposable container #7298
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov Report
@@ Coverage Diff @@
## 3.x #7298 +/- ##
==========================================
Coverage 99.53% 99.54%
- Complexity 6744 6783 +39
==========================================
Files 747 751 +4
Lines 47347 47489 +142
Branches 6376 6378 +2
==========================================
+ Hits 47129 47275 +146
+ Misses 98 95 -3
+ Partials 120 119 -1
Continue to review full report at Codecov.
|
vanniktech
approved these changes
Jul 17, 2021
sakibguy
added a commit
to sakibguy/RxJava
that referenced
this pull request
Jul 18, 2021
3.x: Add subscribe with disposable container (ReactiveX#7298)
1 task
This was referenced Oct 18, 2021
1 task
1 task
1 task
1 task
1 task
1 task
1 task
1 task
1 task
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose
With the existing lambda-subscribe methods, the returned
Disposable
is often added to aCompositeDisposable
but generally is not removed right when the source terminates but when the parent context callsclear()
on the composite. This can lead to unintended retention of resources captured by the lambdas as well as the composite growing and growing with now dead consumers.These new overloads will interact with the container by adding themselves and removing themselves during the consumer's lifecycle.
Resolves #7295
Description
Wraps the given
onXXX
callbacks into aDisposable
Subscriber
/Observer
/etc.,adds it to the given
DisposableContainer
(such asCompositeDisposable
) and ensures, that if the upstreamterminates or this particular
Disposable
is disposed, theSubscriber
/Observer
/etc. is removedfrom the given composite.
The
Subscriber
/Observer
/etc. will be removed after the callback for the terminal event has been invoked.Example
Credits
This code was uplifted and adapted from the RxJavaExtensions project of mine: https://github.com/akarnokd/RxJavaExtensions#subscribeautodispose