Last active
April 12, 2019 14:24
-
-
Save wKoza/de94eda0bf405fc49bbdcd849072e606 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 MyHandlerService(backend, injector, HTTP_INTERCEPTORS_1)); | |
} | |
} | |
@Injectable() | |
export class Http2Service extends HttpClient { | |
constructor(backend: HttpBackend, private injector: Injector) { | |
super(new MyHandlerService(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