shareReplay source subscription persistence limits
26K reputation · 15 Dec 2021, 17:06 UTC
Source Connection Management
The shareReplay operator is used to multicast a source Observable and buffer a specific number of emissions for late subscribers. A critical design consideration is how the operator manages the underlying subscription to the source when the number of active observers reaches zero.
Configuration Uncertainty
By default, shareReplay may maintain the connection to the source indefinitely, even after all downstream observers have unsubscribed. While the refCount configuration property is available to automate unsubscription, the precise behavior regarding buffer retention and source reconnection varies based on the configuration object used.
- Does the internal buffer persist after the source is unsubscribed via
refCount: true? - What is the expected behavior for the source subscription when a new observer arrives after a complete teardown?