My problem is as follows: I use the package api-client-generator (https://www.npmjs.com/package/api-client-generator) which uses two InjectionTokens to build API requests. These tokens include the API domain and HTTP options.
In my application, I only receive information about the API domain and the HTTP options (clientId etc.) at a later point in time. The data is requested asynchronously and then written to a store via NGRX.
Now I would like to somehow provide the asynchronously received data via the InjectionTokens. However, these are built before the application is bootstrapped. Now, since the latest Angular versions (I use NG19), there is provideAppInitializer as a way to initialize data before bootstrapping.
What is noticeable, however, is that I previously used the APP_INITIALIZER token in Angular 17 and the factory call to this token was executed BEFORE all other InjectionTokens were built. This made it possible to reference data in the InjectionTokens within the AppModule that was previously retrieved within APP_INITIALIZER, e.g. via API request, and stored in a central location (here in the NGRX store).
Since Angular 19, the hierarchy has (apparently) changed. The InjectionTokens are still built before provideAppInitializer and only then is the function referenced in provideAppInitializer executed.
As a result, some data within the InjectionTokens is undefinded because it has not yet been retrieved via the API.
Is it always the case that provideAppInitializer is only called after the InjectionTokens have been created? Is there an intelligent alternative how I can provide the two tokens for the api-client-generator only after I have received the data by request via an API interface?
Calling provideAppInitializer in main.ts to retrieve necessary data before creation of InjectionTokens. Unfortunately provideAppInitializer gets called after creation of InjectionTokens (in my case, Angular 19).
provideAppInitializeris just a wrapper aroundAPP_INITIALIZERthere should be absolutely no difference. If you can provide a repro that exhibits such issue, it would be interested !