Merged
Conversation
267994f to
750fe60
Compare
JakeWharton
approved these changes
Dec 20, 2016
Current coverage is 95.62% (diff: 100%)@@ 2.x #4930 diff @@
==========================================
Files 586 587 +1
Lines 37452 37519 +67
Methods 0 0
Messages 0 0
Branches 5627 5644 +17
==========================================
+ Hits 35833 35877 +44
- Misses 682 696 +14
- Partials 937 946 +9
|
Contributor
|
Great improvement, thanks! In one of my projects I applied this transformer to a lot of sequences: private static final CompletableTransformer cache = completable ->
completable.toObservable()
.cacheWithInitialCapacity(1)
.ignoreElements(); |
This file contains hidden or 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
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.
This PR adds the operator
cache()toCompletableto cache the terminal event of aCompletablesequence.I came across the need for this when answering a question where the intent of using
Completablewas to indicate an operation has completed but not actually trigger the operation whenever one subscribed.A small drawback, just like with other
cache()operators is that once connected, there is no way for cancel it from within the operator itself. ReturningCompletable & Disposabledoesn't work because of the the type restriction ofRxJavaPlugins.onAssembly. There could be acache(Consumer<? super Disposable> onDispose)overload or an example showingsource.ambWith(disposer).cache().