-
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
2.x: Add Completable.takeUntil(Completable) operator #6079
Conversation
Codecov Report
@@ Coverage Diff @@
## 2.x #6079 +/- ##
============================================
+ Coverage 98.23% 98.26% +0.02%
- Complexity 6189 6194 +5
============================================
Files 666 667 +1
Lines 44806 44856 +50
Branches 6206 6211 +5
============================================
+ Hits 44014 44076 +62
+ Misses 249 238 -11
+ Partials 543 542 -1
Continue to review full report at Codecov.
|
} | ||
|
||
void innerComplete() { | ||
if (once.compareAndSet(false, true)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Emit error if called more than once?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. It could legitimately lose a race against onComplete
and we don't do it for any other operator either.
@CheckReturnValue | ||
@Experimental | ||
@SchedulerSupport(SchedulerSupport.NONE) | ||
public final Completable takeUntil(CompletableSource other) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the bird has already flown with this one but the operator take
refers to onNext
events and we are more or less using it for all event types (take till terminates or the other thing terminates). I'm not suggesting a change perhaps a naming review for 3.x.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it more discoverable this way and besides, the main behavior of takeUntil
is to stop the main source and complete the downstream, regardless of there could be items from the main source or not.
Shouldn't there be a |
@sailorpsy PR welcome. |
This PR adds the missing dedicated
takeUntil
operator toCompletable
.Previously, the same effect could be achieved via the
ambWith
but there are two benefits of a dedicated operator:takeUntil
operator in other typesambWith
which is built upon an N-aryamb
operator with additional overhead.There was a feature request in #3708 some time ago but apparently the issue got closed off after
Single.takeUntil
was implemented.