💼 This rule is enabled in the following configs: ✅ recommended
, 🔒 strict
.
This rule effects failures if the shareReplay
operator is used - or if it is used without specifying a config
argument.
The behavior of shareReplay
has changed several times - see the blog post linked below.
Name | Description | Type | Default |
---|---|---|---|
allowConfig |
Allow shareReplay if a config argument is specified. | Boolean | true |
This rule accepts a single option which is an object with an allowConfig
property that that determines whether shareReplay
is allow if a config argument is specified. By default, allowConfig
is true
.
{
"rxjs-x/no-sharereplay": [
"error",
{ "allowConfig": true }
]
}
If you are confident that shareReplay
is used properly your project,
then you may not need this rule.
However, keep in mind that it's recommended to always provide a config object
that explicitly specifies refCount
(see linked blog post);
by default, shareReplay
without any config defaults to refCount: false
,
which means the source observable will never be unsubscribed from,
potentially leading to unexpected behavior and memory leaks.