Skip to content

Conversation

@yjaaidi
Copy link
Contributor

@yjaaidi yjaaidi commented Nov 6, 2024

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:

What is the current behavior?

This PR fixes the issue described here: #58493 (comment)

Currently, APP_INITIALIZER providers are transformed into:

provideAppInitializer((service: Service) => {
  return () => service.init();
})(inject(Service)));

What is the new behavior?

provideAppInitializer(() => {
  const initializerFn = ((service: Service) => {
    return () => service.init();
  })(inject(Service));
  return initializerFn();
});

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

This PR also adds support to the useFactory() {} method shorthand.
Let me know if you want me to separate this into a distinct PR.

@pullapprove pullapprove bot requested a review from crisbeto November 6, 2024 00:55
@yjaaidi
Copy link
Contributor Author

yjaaidi commented Nov 6, 2024

cc. @cexbrayat @devversion

@yjaaidi yjaaidi force-pushed the refactor/fix-provide-initializer-use-factory-migration branch from 26f1580 to ab80174 Compare November 6, 2024 01:39
@pkozlowski-opensource pkozlowski-opensource added the area: migrations Issues related to `ng update`/`ng generate` migrations label Nov 6, 2024
@ngbot ngbot bot added this to the Backlog milestone Nov 6, 2024
@JeanMeche JeanMeche added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Nov 20, 2024
@JeanMeche JeanMeche removed the request for review from crisbeto November 20, 2024 23:52
@JeanMeche JeanMeche force-pushed the refactor/fix-provide-initializer-use-factory-migration branch from ab80174 to f3937d5 Compare November 21, 2024 00:02
Priori to this commit, initializer functions with dependencies were not migrated correctly.
With this commit, the function is executed in a injection context to allow the usage of `inject`.
@JeanMeche JeanMeche force-pushed the refactor/fix-provide-initializer-use-factory-migration branch from f3937d5 to 187dd42 Compare November 21, 2024 00:09
thePunderWoman pushed a commit that referenced this pull request Nov 21, 2024
…ory (#58518)

Priori to this commit, initializer functions with dependencies were not migrated correctly.
With this commit, the function is executed in a injection context to allow the usage of `inject`.

PR Close #58518
@thePunderWoman
Copy link
Contributor

This PR was merged into the repository by commit 1fe001e.

The changes were merged into the following branches: main, 19.0.x

@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 Dec 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: migrations Issues related to `ng update`/`ng generate` migrations target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants