-
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
[docs] Is the order of merge guaranteed? #3244
Comments
There's actually a test which seems to verify the order stability:
As I said, I guess this should be documented. |
You can use |
But
Here, using |
@Airblader My understanding of the guarantee is that the observables will be subscribed to in the order in which they are passed. With your example: Observable.merge(
Observable.interval(1000).startWith(1),
Observable.interval(1000).startWith(2),
)
.subscribe(console.log);
There is no guarantee that the timer-emitted values from the first and second observables will be received in that order. The test you referenced can rely upon seemingly similar behaviour because the |
Yes, that's fine. I'm only talking about the synchronous emissions. The timers were just there to show that "use concat instead" isn't an answer. :-) |
This seems like the behavior of the recursive scheduler. Can you read https://staltz.com/primer-on-rxjs-schedulers.html and see if that answers most of your concerns? |
@staltz It does, yes, thanks. My concern was actually the documentation. I'm not extremely happy with the fact that a user would have to dig into schedulers to find out whether the order in this case is guaranteed or not, though. |
the order of subscription is gauranteed. The order of events coming out would depend on what you're subscribing to, It's just raw function calls out of the back. |
Closing in favor of an issue on the docs repository: ReactiveX/rxjs-docs#241 |
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. |
While answering a question I actually came across the thought of whether the order of a
merge
d observable is guaranteed if the input observables emit synchronously. Consider this example:Is this guaranteed to emit
1
and then2
or could it also be the other way around? I'm not so much asking about the current implementation but about the contract themerge
operator gives me.Whatever the answer, it should probably be documented. The current docs don't seem to mention the order at all.
The text was updated successfully, but these errors were encountered: