-
Notifications
You must be signed in to change notification settings - Fork 3k
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
fix(race): unsubscribe raced observables with immediate scheduler #2158
Conversation
Fixed the bug where racing an Observable that emits immediately, with default scheduler, leaves other raced Observables unsubscribed forever. Now immediate emit makes the race ignore following Observables.
Looks good to me. |
LGTM, but can the unit tests be implemented as marbles like the rest of them? |
haven't tried it yet but seems some of the test may able to use marbles. @ktkiiski, what do you think? |
I actually first wrote the specs with marbles, but they did not bust the original bug. This is probably because the marble tests are based on |
Ahhhh forgot that. |
After reviewing the source, it seems the test cold Observables are missing the ability to synchronously emit values on subscription. I was expecting something like |
LGTM as well. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description:
This fixes a bug with the
race
operator: whenever a raced Observable emitted a value immediately when subscribed (with the default scheduler), any following Observables were subscribed but never unsubscribed.Now, if any raced Observable emits a value immediately, any latter Observables are ignored, because for them "the race is already lost".
Also, it is now ensured that the immediately emitting Observable is still added to the
RaceSubscriber
and will be unsubscribed once the outer Observable is unsubscribed.