As you know it\'s possible to use Interceptors in new versions of Angular 4.
In mine, I want to cancel a request in interceptor in some conditions. So i
This is just a slight variant of RVP's answer
import { NEVER } from 'rxjs';
intercept(request: HttpRequest, next: HttpHandler): Observable> {
if (stopThisRequest) {
return NEVER;
}
return next.handle(request);
}
I used NEVER
instead of EMPTY
to avoid dealing with undefined values in my subscriptions (or promises).
Use NEVER
if you don't want your subscription callback to be invoked