- Angular 13
NOTE: Replace x.x.x
with the version.
$ cd $YOUR_APP_PATH
$ curl -OL https://github.com/iwstkhr/ngx-auto-destroy-deco/raw/main/iwstkhr-ngx-auto-destroy-deco-x.x.x.tgz
$ npm add iwstkhr-ngx-auto-destroy-deco-x.x.x.tgz
Just add:
@AutoDestroy
decorator- Class field used for
takeUntil
notifier
@Component({
selector: 'app-sample',
templateUrl: './sample.component.html',
})
@AutoDestroy()
export class SampleComponent implements OnInit {
private readonly onDestroy$ = new Subject<void>();
ngOnInit() {
interval(1000).pipe(
takeUntil(this.onDestroy$),
);
}
}
MIT