Which @angular/* package(s) are relevant/related to the feature request?
common
Description
When using class based interceptors we were able to just provide a token and it would be registered.
providers: [
{
provide: HTTP_INTERCEPTORS,
useClass: ErrorsInterceptor,
multi: true,
}
]
This gave us the possibility to just provide this token and the DI would do it's job to register the interceptor.
With functional http interceptors, we loose this ability because we have to register them using the withInterceptor() method inside provideHttpClient() like this:
providers: [
provideHttpClient(withInterceptors([errorInterceptor]))
]
This is great until we need to add providers or interceptors from a library. For example:
providers: [
provideHttpCache()
]
I want to be able register some http interceptors from this provider function directly (just like we were able to do it before).
Proposed solution
Maybe expose HTTP_INTERECPTOR_FNS so we can just provide this token with our providers just like before.
Or expose a method that provides this token with our value.
Sth like:
provideInterceptors([errorInterceptor])
Alternatives considered
Use class based interceptors.