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
shareoperator 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 onnextemissions or external signals.Proposed API
Extend
ShareConfig<T>with:Notes
resetOnNextandresetOngives us the ability to have the defaults for both be false instead of undefinedresetOnNextintentionally does not accept true, because unconditional reset on every emission defeats the purpose of sharing.resetOnsince a truthy value doesn't make sense: we need some value to trigger onhandleReset()infrastructure and offers significant expressive power with minimal added complexity.sharewithout 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
resetOnErrorandresetOnComplete.Beta Was this translation helpful? Give feedback.
All reactions