title: Cancel all pending http request with Angular Interceptor
body: <p>My interceptor:</p>
  
  <pre><code>constructor(router: Router,
          private httpCancelService: HttpCancelService) {
          router.events.subscribe(event =&gt; {
              if (event instanceof ActivationEnd) {
                  this.httpCancelService.cancelPendingRequests();
              }
          });
      }
  
      intercept&lt;T&gt;(req: HttpRequest&lt;T&gt;, next: HttpHandler): Observable&lt;HttpEvent&lt;T&gt;&gt; {
          return next.handle(req).pipe(takeUntil(this.httpCancelService.onCancelPendingRequests()));
      }
  </code></pre>
  
  <p>My cancel service:</p>
  
  <pre><code> private pendingHTTPRequests$ = new Subject&lt;void&gt;();
  
      constructor() { }
  
  
      public cancelPendingRequests() {
          this.pendingHTTPRequests$.next();
      }
  
      public onCancelPendingRequests() {
          return this.pendingHTTPRequests$.asObservable();
      }
  </code></pre>
  
  <p>It is working perfectly for me but the problem I have is that when I change the route to a route that generates several initial requests, it cancels the pending requests of my previous route and cancels the request of my current route.</p>
  
  <p><strong>What can I do so that I only cancel the pending requests of my previous route and do not touch any request of my current route</strong></p>
  
  <p>thanks!!</p>