-
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
Change behavior of shareReplay #5894
Comments
Changing it (again) will break and confuse other developers: https://ncjamieson.com/whats-changed-with-sharereplay/ IMO, devs using |
@cartant Thanks for your reply. I appreciate the last changes on But my suggestion is about how I don't know how to achieve my suggested behavior by using the config argument. |
Completion effects unsubscription for all subscribers - dropping the ref count to zero - so the two are directly related. |
Sure, but the ref count drops to zero independently of the reference counting setting being active or inactive. This is what I meant with it's independently from the config setting
|
Okay, I see what you mean. The replaying of the const shared = source.pipe(
multicast(() => new ReplaySubject(/* whatever */)),
refCount()
); It's likely that the multicasting infrastructure will be replaced in version 7 with something that's more flexible and will let you specify the reset-on-complete behaviour in the configuration passed to However, those changes will still include a |
Closing for the reasons mentioned in the comment above. |
The solution for version 7 for the equilavent of shareReplay({ refCount: true, bufferSize: 1}) with reset for completed observables is: share({
connector: () => new ReplaySubject(1),
resetOnError: true,
resetOnComplete: true,
resetOnRefCountZero: true
}) |
Feature Request
Is your feature request related to a problem? Please describe.
I'm always confused by the current implementation of
shareReplay
because it behaves different than theshare
operator.Describe the solution you'd like
It want to suggest
shareReplay
should reconnect to the source if the source was completed and a new observer subscribes. But not like in rxjs 5. It should still replay the lastn
values of the completed source on new subscription.This is an example implementation.
Additional context
I created a Stackblitz to demonstrate the desired behavior.
The text was updated successfully, but these errors were encountered: