-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New operators: concatEmptyWith
and mergeEmptyWith
.
#3060
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
Conversation
Marked the new operators as |
Renamed operators to Also, removed the |
Waiting on confirmation of names: #3037 (comment) |
* an item. So, this usually is useful for {@code Observable<Void>} and results in cleaner code as opposed to using | ||
* a {@link #cast(Class)}, something like: | ||
* | ||
{@code Observable.<Void>empty().cast(String.class).concatWith(Observable.just("Hello"))} |
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.
nit: no *
before the line
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.
Done
continueWith
and mergeError
.concatEmptyWith
and mergeEmptyWith
.
/*Nothing from this producer will ever be requested as we never expect any items to be emitted from the | ||
parent. The only thing w.r.t backpressure that is required is to store the requested count from the | ||
child till the time the alternate observable is subscribed. So, this producer is just ignored and the | ||
configured EmptyProducer on the child stores any buffered requested items till subscription to alternate.*/ |
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.
How does the subscriber know the producer doesn't emit if we never request it too?
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 think if the this should call producer.request(Long.MAX_VALUE);
.
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.
If the operator uses ProducerArbiter
, the child request will reach the main source and there is no need for extra requests.
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 have added producer.request(Long.MAX_VALUE)
to the source Observable
for both the operators.
There was a thought to send the request
to the source only after the subscriber requested anything. Although, this made sense but in this context, it was not making much of a difference but adding complexity of synchronization between request(n)
and setProducer()
. The argument against being that for a source that never emits an item, should the terminal events be delayed till request(n)
or a subscription indicates start of processing.
Thanks @akarnokd for the review. |
As discussed in issue ReactiveX#3037, the primary use of these operators is to be applied to `Observable<Void>` so that they can be merged and concatenated with an Observable of a different type. Both these operators raise an error if the source Observable emits any item. Review comments
Apart from the open discussions, I think I am ready for another round of review. The travis build failed because of the test rx.BackpressureTests > testMergeAsyncThenObserveOn failing. I don't think my changes have anything to do with that, is that a flaky test? |
} | ||
|
||
if (requestToAlternate) { | ||
this.altProducer.request(missedRequested); |
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.
You access missedRequested
and altProducer
outside of their guard.
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.
Fixed
@akarnokd It seems you have open questions/issues on this PR still, is that correct? |
public void onCompleted() { | ||
synchronized (this) { | ||
if (parentCompleted) { | ||
delegate.onCompleted(); |
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.
You shouldn't call onXXX methods while holding a lock.
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.
duhh .. that was a bad oversight at my end. Thanks for catching it!
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.
Fixed
@benjchristensen Found a few problems with this PR in the meantime. |
@akarnokd I would wait for your further comments to make all changes together. So, get the review comments coming, they are good :) |
@NiteshKant is this ready to be merged? |
sigificent -> significant alreay -> already
…etryWithPredicate
…ed commit) Squashed commits: [c6e43fc] 1.0.15. Beta/Deprecation of Subject state peeking methods. This should give users one release to prepare for the class structure changes.
This came up in a [Stackoverflow](http://stackoverflow.com/questions/32889008/do-operators-instead-of-a-whole-subscriber) answer. If the doOnError's callback or the doOnEach's onError method throws, any non-fatal exception replaced the original error which got lost. This PR will wrap them both into a CompositeException. 2.x note: since Java 8 supports `addSuppressed` all callbacks in this situation either attach to the original exception or the original exception is attached to the callback's exception.
Slight change to make the distinction between `@Beta` and `@Experimental` explicit and meaningful.
As discussed in issue ReactiveX#3037, the primary use of these operators is to be applied to `Observable<Void>` so that they can be merged and concatenated with an Observable of a different type. Both these operators raise an error if the source Observable emits any item.
Conflicts: src/main/java/rx/internal/operators/OperatorConcatEmptyWith.java src/main/java/rx/internal/operators/OperatorMergeEmptyWith.java
I addressed the open comments apart from the suggestion of calling I see that my rebase caused a bazillion other commits to show here, may be I should close this and issue a new PR? |
Please do create a new and clean PR. |
As discussed in issue #3037, the primary use of these operators is to be applied to
Observable<Void>
so that they can be merged and concatenated with an Observable of a different type.Both these operators raise an error if the source Observable emits any item.