Angular 2+ - Unsubscribe for pros
Declarative way to unsubscribe from observables when the component destroyed
Installation
npm install angular2-take-until-destroy --save
Usage
; @@TakeUntilDestroy implements OnDestroy componentDestroy; { const timer$ = Observable } // If you work with AOT this method must be present, even if empty! // Otherwise 'ng build --prod' will optimize away any calls to ngOnDestroy, // even if the method is added by the @TakeUntilDestroy decorator { // You can also do whatever you need here }