Feature Request: resetOnNext
and resetOn
support for share
#7560
pcbowers
started this conversation in
Ideas / Feature request
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Motivation
Having the ability to reset a
share
operator arbitrarily based on emitted values or external triggers would be incredibly useful, especially in scenarios like:{ type: 'reset' }
)The existing reset options (
resetOnError
,resetOnComplete
, andresetOnRefCountZero
) are tied to lifecycle events, but there's currently no mechanism to reset based onnext
emissions or external signals.Proposed API
Extend
ShareConfig<T>
with:Notes
resetOnNext
andresetOn
gives us the ability to have the defaults for both be false instead of undefinedresetOnNext
intentionally does not accept true, because unconditional reset on every emission defeats the purpose of sharing.resetOn
since a truthy value doesn't make sense: we need some value to trigger onhandleReset()
infrastructure and offers significant expressive power with minimal added complexity.share
without affecting current usage.Examples
Reset on specific value:
Reset with delay after special value:
Reset on internally handled errors
Time-based resets
Manual resets via Subject
Implementation Sketch
This follows the same pattern already used by
resetOnError
andresetOnComplete
.Beta Was this translation helpful? Give feedback.
All reactions