Loading...
Loading...
ALWAYS use when working with Angular DestroyRef, takeUntilDestroyed, or cleanup in Angular.
npx skill4agent add oguzhan18/angular-ecosystem-skills angular-destroyrefimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';
@Component({})
export class MyComponent {
private destroyRef = inject(DestroyRef);
ngOnInit() {
this.data$.pipe(
takeUntilDestroyed(this.destroyRef)
).subscribe();
}
}@Injectable({ providedIn: 'root' })
export class DataService {
private destroyRef = inject(DestroyRef);
getData() {
return this.http.get('/api/data').pipe(
takeUntilDestroyed(this.destroyRef)
);
}
}