There are easy situations to get into where takeUntil()
doesn’t behave as expected. One article that I like to recommend to people is this one https://ncjamieson.com/avoiding-takeuntil-leaks/
My source for this advice came from talks by various people in the community and from discussions with Ward Bell and John Papa during the last ngConf. The reason given is because takeUntil
is not guaranteed to work and actually can still leak subscriptions. I don’t think this is well documented and why I want to share this information with people who are very well informed.
This is a fairly recent discovery. Most of what you read online will still follow the advice from Netaniel Basel’s article about not unsubscribing. That was a great article and I followed that advice until John Papa’s talk at ngConf 2019 where the issues were pointed out. It was reiterated this year at ngConf 2020.
Here is John Papa’s talk entitled These ARE the Angular Tips You Are Looking For. https://www.youtube.com/watch?v=2ZFgcTOcnUg
It is an excellent talk, but at 3:22 is when he starts talking about subscriptions and then eventually moves into issues with takeUntil()