Skip to content

Conversation

@krishpranav
Copy link

PR Checklist:

Please check if your PR fulfills the following requirements:

PR Type:

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

PR Description:

Right now, HttpFeature only accepts Provider[], which makes it harder to extend the HTTP client with custom features. This change lets it also accept EnvironmentProviders, making it easier to customize things like interceptors or backend replacements. provideHttpClient() already converts providers to EnvironmentProviders, so this just makes the API more consistent. 🚀

@pullapprove pullapprove bot requested a review from thePunderWoman February 16, 2025 10:09
};
}

export function provideHttpClient(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any change to provideHttpClient should be done in packages/common/http/src/provider.ts where it's located.

): EnvironmentProviders {
return makeEnvironmentProviders(
features.flatMap((f) =>
f.ɵproviders.map((provider) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this breaks existing providers

const result = provideHttpClient(customFeature);

expect(result).toBeDefined();
expect(result).toEqual(jasmine.any(Object));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't test that the providers works correctly.

@thePunderWoman thePunderWoman added the area: common Issues related to APIs in the @angular/common package label Feb 18, 2025
@ngbot ngbot bot added this to the Backlog milestone Feb 18, 2025
@JoostK
Copy link
Member

JoostK commented Feb 18, 2025

which makes it harder to extend the HTTP client with custom features

This is an intended design choice, features are not open-ended and therefore not designed to be extended.

I'm closing this PR for now; any discussion can happen in #59670.

@JoostK JoostK closed this Feb 18, 2025
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Mar 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area: common Issues related to APIs in the @angular/common package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants