Skip to content
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

ShareReplayConfig['refCount'] typing does not accept a function #7138

Closed
yastanotheruser opened this issue Dec 29, 2022 · 5 comments
Closed

Comments

@yastanotheruser
Copy link

Describe the bug

According to the docs, shareReplay configuration should accept a function refCount that allows controlling unsubscription, but the ShareReplayConfig interface defines refCount as boolean only.

export interface ShareReplayConfig {
bufferSize?: number;
windowTime?: number;
refCount: boolean;
scheduler?: SchedulerLike;
}

Expected behavior

ShareReplayConfig['refCount'] should have the same type as ShareConfig['resetOnRefCountZero'].

Reproduction code

// Typing issue, functionality is not affected.

Reproduction URL

No response

Version

7.8.0

Environment

No response

Additional context

No response

@kwonoj
Copy link
Member

kwonoj commented Dec 29, 2022

According to the docs

Not sure which part of the docs refers it. Mind elaborate?

@yastanotheruser
Copy link
Author

It doesn't explicitly mention what signature but this part is what I'm referring to:

As of RXJS version 6.4.0 a new overload signature was added to allow for manual control over what happens when the operators internal reference counter drops to zero.

Since refCount is actually passed as a resetOnRefCountZero property to share, their types should be identical.

@kwonoj
Copy link
Member

kwonoj commented Dec 29, 2022

That sentence is backed up by

If refCount is true, the source will be unsubscribed from once the reference count drops to zero, i.e. the inner ReplaySubject will be unsubscribed. All new subscribers will receive value emissions from a new ReplaySubject which in turn will cause a new subscription to the source observable.

Nothing explicilty said config will accept user function.

@kwonoj kwonoj closed this as completed Dec 29, 2022
@yastanotheruser
Copy link
Author

yastanotheruser commented Dec 29, 2022

Boolean values don't allow to define manual control of the unsubscription, which is allowed by share (as shown in this example) but not by shareReplay.

@Evertt
Copy link

Evertt commented Mar 31, 2024

@kwonoj why did you close this issue? This issue is totally valid. It's totally valid to wish to have the same configuration options that the share() operator offers. I would also like to be able to use shareReplay() and configure it to resetOnRefCountZero using a delay of a couple seconds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants