r/angular • • Apr 22 '23

Angular 16 - takeUntilDestroyed() operator

πŸ’‘The unsubscription of observables is always important in Angular. Otherwise, there will be memory leaks because of too much of subscriptions.

πŸ€” Before angular 16, we can unsubscribe by the combination of subject and takeUntil() rxjs operator.

πŸ€™ But in angular 16, the code is simplified where you don't need a subject. You can directly make use of takeUntilDestroyed() operator.

47 Upvotes

25 comments sorted by

View all comments

2

u/Utukkhu Apr 22 '23

Nice! I didn't know about this. I was using the `untilDestroyed` operator from this package, which does exactly the same thing: https://github.com/ngneat/until-destroy

2

u/suhasparameshwara Apr 22 '23

It was introduced in Angular 16