DEV Community

Discussion on: This Angular helper function has saved me from memory leaks for 4 years

Collapse
 
danielsc profile image
Daniel Schreiber

This is an important pattern. For me this library solved this pretty elegantly: github.com/ngneat/until-destroy

Collapse
 
gempain profile image
Geoffroy Empain

Interesting library ! I like the .pipe(untilDestroyed(this)) pattern. The annotation is also quite clean as well. The only disadvantage of an annotation is that you don't directly see the link between the unsubscribe and the actual code. The pipe forces you to manually unsubscribe, IMO makes the code easier to maintain, and is syntactically nicer than pushing into the array. Good one :)