BACK
ReferencerefCount
Reference · 92

refCount

refCount

Deprecated
rxjs.dev

Helper for auto-connecting a connectable Observable.

Signature

refCount(): MonoTypeOperatorFunction

What it does

Connects a connectable source on the first subscriber and disconnects on the last unsubscription. Usually used after publish/multicast.

When to use

Supporting legacy code. In new code, refCount is usually replaced by share/shareReplay options.

Deprecated API

Marked deprecated in RxJS 7. In new code, use share({ resetOnRefCountZero: true }) or shareReplay({ refCount: true }).

See also

share, shareReplay

script.ts // TypeScript
CONSOLE · Console output
Hit Run to see the result...