-
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
Added the switch operator to Observable #259
Added the switch operator to Observable #259
Conversation
RxJava-pull-requests #126 SUCCESS |
|
||
@Override | ||
public void onNext(Observable<T> args) { | ||
synchronized (subscription) { |
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.
We don't need to synchronize as we expect the sequence to comply with the Rx contract. This adds performance overhead that we don't want to add.
See Rx Design Guidelines 6.8 for more background on this.
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.
Thanks for the guidelines. That does make more sense in terms of performance.
RxJava-pull-requests #128 SUCCESS |
Since the onError discussion is now part of an outdated diff ... moving it here: I believe it needs to be this:
It's the same way with I could see an overload of We can't just swallow errors though so if an onError is received from a child sequence it must behave as if the parent received an onError and unsubscribe and pass on the error. |
I've modified the Ideas, thoughts? |
RxJava-pull-requests #146 SUCCESS |
RxJava-pull-requests #147 SUCCESS |
That's a good point ... there could be a race condition (very unlikely but possible). The only way I can think of checking it is keeping a boolean flag that we're supposed to be finished and if we receive more onNext/onError notifications we continue to unsubscribe each time (and not send those events through). |
I'll make that change as I do some other cleanup before 0.9 is released. |
Added the switch operator to Observable
Thank you @michaeldejong for this submission. |
Actually AtomicObservableSubscription already handles this case in the public AtomicObservableSubscription wrap(Subscription actualSubscription) {
if (!this.actualSubscription.compareAndSet(null, actualSubscription)) {
if (this.actualSubscription.get() == UNSUBSCRIBED) {
actualSubscription.unsubscribe();
return this;
}
throw new IllegalStateException("Can not set subscription more than once.");
}
return this;
} If the |
Added the switch operator to Observable
* Add response predicate to retry sync and async for enhancement ReactiveX#259 * ReactiveX#258 add the support to the webflux types in the circuit breaker annotation AOP * ReactiveX#258 review comments * ReactiveX#258 review comments
* Add response predicate to retry sync and async for enhancement ReactiveX#259 * ReactiveX#348 add sync retry spring boot annotation and config support for spring boot 1 and 2 * ReactiveX#348 add sync retry spring boot annotation and config support for spring boot 1 and 2 * ReactiveX#348 adding java doc * ReactiveX#348 adding java doc * ReactiveX#348 adding spring override bean option for the retry spring boot starters * ReactiveX#348 adding spring async retry aspect support * ReactiveX#348 adding annotation validation protection of using retry and async retry annotation together in the class level * ReactiveX#348 updating java doc * ReactiveX#348 adding the new prefix of async retry metrics and fixing the merge conflicts * ReactiveX#348 covering review comments * ReactiveX#348 removing unneeded lines * ReactiveX#348 adding the updated spring boot documentation for the retry spring boot usage for spring boot 1 and 2 * ReactiveX#348 documentation review comments * ReactiveX#348 documentation review comments and removing health indicators for retry support in spring boot * ReactiveX#348 documentation review comments
* Add response predicate to retry sync and async for enhancement ReactiveX#259 * ReactiveX#317 skipping Java Error type from onError Rx retry transformer * ReactiveX#317 adding proper comment
I've implemented the switch operator for
Observable
sequences (see issue #13). Because "switch" is a keyword in Java I have opted for switchDo. This matches to the finallyDo method which represents the finally operator and has the same naming problem.Please let me know if you have any feedback.