-
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
behaviour of publish + refCount !== share? #1363
Comments
I don't know the specifics, but from the source it looks like |
@christianacca @plievone yes, we finally decided to fix a long-standing backwards-incompatible bug with |
OK, I see that was a hard decision to make. Of course expect this to trip quite a number of devs up simply because there are a lot of existing historical mentions (eg) that |
Related issue: #1914 It would be good to fix the docs here to avoid further confusion. |
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. |
Problem
My understanding is that
share
meant to be a shorthand equivalent topublish().refCount()
- is my understanding correct?If so then, I have noticed that there are cases where this is not so.
Example
Note: for the running example open codepen
Take for example:
The subscribed observer receives items emitted from
movieListFetched$
but NOT fromqueuedMoviesFetched$
.Whereas the if you replace the
publish().refCount()
with:... the subscriber end up receiving items from BOTH
movieListFetched$
andqueuedMoviesFetched$
.My guess at an explanation
My guess is that with
publish().refCount()
, the observable produced (urlPrefixFetched$
) is not being disconnected when theconcat
operator switches from emitting items from the second observable.As a consequence
fakeUrlPrefixFetch$
is already completed.On the other hand with
share
, at the point ofconcat
moving between observables,urlPrefixFetched$
's ref count drops to 0. It is then reconnected to causing the cold observable (urlPrefixFetch$
) to emit a new set of (1) items.The text was updated successfully, but these errors were encountered: