Apakah ada cara untuk berhenti berlangganan panggilan http dari layanan sudut onDestroy hook.
P.S. Saya mengetahui operator 'ambil' rxjs atau berhenti berlangganan layanan dari komponen itu sendiri.
import { HttpClient } from "@angular/common/http";
import { Injectable, OnDestroy } from "@angular/core";
@Injectable()
export class SampleService implements OnDestroy {
constructor(private httpClient: HttpClient) {}
getSampleData() {
return this.httpClient.get("https://jsonplaceholder.typicode.com/todos/1");
}
ngOnDestroy(): void {
// automatically unsubscribe to service.
}
}