3 ms·
It's ironic that the author's recommendation of using `shareReplay(1)` actually leaks a subscription as well. Unless the operator is a supplied with `{ refCount
by stupidcar 8y ago
It's ironic that the author's recommendation of using `shareReplay(1)` actually leaks a subscription as well. Unless the operator is a supplied with `{ refCount: true }` config parameter, it does not unsubscribe from the source observable, even when all its subscribers unsubscribe: https://github.com/ReactiveX/rxjs/blob/master/src/internal/operators/shareReplay.ts#L114 https://github.com/ReactiveX/rxjs/blob/master/src/internal/o...
Sadly, issues like this seem to crop up all the time when using reactive programming. I'm not as anti-reactive as most other commenters here seem to be, but there's no doubt that certain areas, particularly memory safety, sharing and buffering, seem hard to understand and get right.
- Eyas 8y agoMy bad. The recommendation at Google is to use publishReplay + refCount precisely for that reason, but surprisingly there's so little public documentation on e.g. the publishReplay rxjs operator, that I decided to go with what was ultimately more prevalent online. Probably worth fixing that though, and creating those resources out there.