IIRC, shareReplay is the problem. There is some debate about its current implementation — which was changed in version 5.5.0-beta.4.

Essentially, the current implementation of shareReplay will never unsubscribe from its source observable. When used, it relies upon the source observable either completing or erroring.

So, yes, you are correct in that placing takeUntil before shareReplay is necessary to effect unsubscription from the source.

Perhaps I should add another rule to rxjs-tslint-rules that warns about shareReplay being used? Or should make the takeUntil rule aware of the shareReplay quirk?

RxJS core team member; front-end developer; mentor; speaker; open-source contributor

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store