NgxInterceptor
Demo
Install
npm i ngx-interceptor
Usage
Add ngx-interceptor to your root app file.
//app.modaule.ts;; ;
<!-- app.component.html -->
Settings
Endpoints filter
The default behavior of the interceptor is to "catch" every http request. However, the component accepts two kind of inputs to filter these endpoints (exceptions or strict) and will filter every request which contain some of the given text. The input endpoints format could be as an array or an object:
;
or
The two different endpoints filters are:
- Exceptions: every endpoint will be intercepted except the given ones
- Strict: only the given endpoints will be intercepted
Lag
The default behavior of the interceptor is to only show the interceptor when there is a lag of 300ms between the request and the response in order to avoid blinking effects. This lag can be modified with the following input:
In this example the time lag has been changed to 500ms.
Color
The interceptor has a default blue (#0051ff) spinner to show when it is waiting a response. The spinner color can be changed easily by the following input (accept any kind of CSS color):
or
or
Custom spinner/modal
Default spinner can be easily replace with a custom spinner or modal wrapping the content inside the ngx-interceptor tag:
//... Add here the custom html content