Performance: Interceptors for request modification
MEDIUM IMPACT
This affects the time it takes for HTTP requests to be sent and responses to be processed, impacting interaction responsiveness and network efficiency.
intercept(req, next) {
const clonedReq = req.clone({ headers: req.headers.set('Authorization', 'Bearer ' + this.token) });
return next.handle(clonedReq);
}intercept(req, next) {
const clonedReq = req.clone({ headers: req.headers.set('Authorization', 'Bearer ' + this.token) });
return next.handle(clonedReq).pipe(delay(100));
}| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Interceptor with delay or heavy sync work | 0 | 0 | Blocks UI update indirectly by delaying response | [X] Bad |
| Lightweight interceptor modifying headers only | 0 | 0 | Minimal impact on UI update speed | [OK] Good |