How to cancel/unsubscribe all pending HTTP requests in Angular 4+
Checkout the takeUntil() operator from RxJS to globally drop your subscriptions : – RxJS 6+ (using the pipe syntax) import { takeUntil } from ‘rxjs/operators’; export class YourComponent { protected ngUnsubscribe: Subject<void> = new Subject<void>(); […] public httpGet(): void { this.http.get() .pipe( takeUntil(this.ngUnsubscribe) ) .subscribe( (data) => { … }); } public ngOnDestroy(): void { … Read more