well I had this code in my angular component
sub: Subscription;
this.sub = this.notificationService
.getNotificationByUser(reqbody).subscribe(res => {});
ngOnDestroy(){
this.sub ? this.sub.unsubscribe() : '';
}
so the problem is, this http request is getting canceled and my portal keeps loading for more than 10 mins after that this api is again getting called with 404 response
but when i did the following
destroy$ = new Subject<boolean>();
this.notificationService
.getNotificationByUser(reqbody).pipe(takeUntil(this.destroy$))
.subscribe(resp => {});
ngOnDestroy() {
this.destroy$.next(true);
}
this api directly returns 404 status without taking long to respond and without prolonged loading
Any idea why is this happening?
Please help