Skip to content

Added interceptor fns als replacement for interceptors#48

Merged
dbeuchler merged 1 commit into
devfrom
feature/interceptor-functions
Jul 15, 2026
Merged

Added interceptor fns als replacement for interceptors#48
dbeuchler merged 1 commit into
devfrom
feature/interceptor-functions

Conversation

@dbeuchler

Copy link
Copy Markdown
Member

Migrated legacy class-based API interceptor into two, single-responsibility Angular functional Interceptors (HttpInterceptorFn).

Additionally, the old class-based components have been explicitly marked as @deprecated.

  • Split the ApiInterceptor into languageInterceptor (adds localization headers) and apiErrorInterceptor (handles global error logging).
  • emoved the need for withInterceptorsFromDi(), explicit class provider injection, and manual multi-provider arrays (API_INTERCEPTOR_PROVIDER) in app.config.ts.
  • Functional interceptors generate less boilerplate code, compile to smaller chunk sizes, and allow for better framework tree-shaking.

Sample:

import { languageInterceptor, apiErrorInterceptor } from './api/api.interceptors';

export const appConfig: ApplicationConfig = {
  providers: [
    provideRouter(routes),
    provideHttpClient(
      withInterceptors([languageInterceptor, apiErrorInterceptor])
    ),
  ],
};

@dbeuchler dbeuchler added this to the v22.x milestone Jul 13, 2026
@dbeuchler
dbeuchler requested a review from 1nf0rmagician July 13, 2026 08:35
@dbeuchler dbeuchler self-assigned this Jul 13, 2026
@dbeuchler dbeuchler added the enhancement New feature or request label Jul 13, 2026
@dbeuchler
dbeuchler merged commit df18d31 into dev Jul 15, 2026
4 checks passed
@1nf0rmagician
1nf0rmagician deleted the feature/interceptor-functions branch July 17, 2026 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants