DEV Community

Discussion on: Surprisingly simple method to increase Firestore performance & reduce cost

Collapse
 
grandschtroumpf profile image
Grandschtroumpf • Edited

Be careful with shareReplay(1). It never unsubscribes in version 6. You need to specify refCount: true as a params to unsubscribe when there is no subscriber anymore. As you can see in the code, the refCount is false by default :
github.com/ReactiveX/rxjs/blob/6.6...
To avoid this pitfall you can do shareReplay({ bufferSize: 1, refCount: true })

Note: I think that this is working as expected in version 7 though