Instantly share code, notes, and snippets.

Embed
What would you like to do?
export const HTTP_INTERCEPTORS_1 = new InjectionToken<HttpInterceptor[]>('HTTP_INTERCEPTORS_1');
export const HTTP_INTERCEPTORS_2 = new InjectionToken<HttpInterceptor[]>('HTTP_INTERCEPTORS_2');
@Injectable()
export class Http1Service extends HttpClient {
constructor(backend: HttpBackend, private injector: Injector) {
super(new MyHandlerService1(backend, injector, HTTP_INTERCEPTORS_1));
}
}
@Injectable()
export class Http2Service extends HttpClient {
constructor(backend: HttpBackend, private injector: Injector) {
super(new MyHandlerService1(backend, injector, HTTP_INTERCEPTORS_2));
}
}
@NgModule({
providers: [
Int1Interceptor, Int2Interceptor, Int3Interceptor,
{provide: HTTP_INTERCEPTORS_1, useClass: Int1Interceptor, multi: true},
{provide: HTTP_INTERCEPTORS_2, useClass: Int2Interceptor, multi: true},
{provide: HTTP_INTERCEPTORS_2, useClass: Int3Interceptor, multi: true},
Http1Service, Http2Service,
],
bootstrap: [AppComponent]
})
export class AppModule {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment