angular-destroyref
Installation
SKILL.md
Angular DestroyRef
Version: Angular 16+ (2025) Tags: DestroyRef, Cleanup, takeUntilDestroyed
References: DestroyRef
Best Practices
- Use takeUntilDestroyed
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
@Component({})
export class MyComponent {
private destroyRef = inject(DestroyRef);
ngOnInit() {
this.data$.pipe(
takeUntilDestroyed(this.destroyRef)
).subscribe();
}
}
- Use in service
@Injectable({ providedIn: 'root' })
export class DataService {
private destroyRef = inject(DestroyRef);
getData() {
return this.http.get('/api/data').pipe(
takeUntilDestroyed(this.destroyRef)
);
}
}
Related skills
More from oguzhan18/angular-ecosystem-skills
angular-tailwind
ALWAYS use when working with Angular and Tailwind CSS, Tailwind configuration, utility-first CSS, or styling Angular applications with Tailwind.
139angular-animations
>-
137rxjs
ALWAYS use when working with RxJS Observables, operators, and reactive patterns in Angular applications.
135angular-material
ALWAYS use when working with Angular Material components, CDK, or Material Design in Angular applications.
131angular-security
ALWAYS use when working with Angular Security, XSS prevention, CSRF protection, Content Security Policy, or sanitization in Angular applications.
130angular-bootstrap
ALWAYS use when working with Angular Bootstrap, ng-bootstrap, Bootstrap components in Angular, or Bootstrap 5 integration.
129