Michele Stieven
1 min readJul 12, 2018

--

The module has to give the possibility to set the config at runtime, for example, the Router of Angular has a resetConfig() method which allows you to do that. If you can’t, you have to override the provider of the module’s config and cross your fingers :) For example, by looking at that module’s code, I’d say you could override OAuthModuleConfig (in your AppModule) with a function like this:

{
provide: OAuthModuleConfig,
useFactory: myFactory,
deps: [myService]
}

const myFactory = (myService: MyService) => myService.getConfig();

Where myService is the service you used in your APP_INITIALIZER to store the JSON info, so at that point getConfig() will already have the data to return. You have to hope that everything which needs the config (for example, the Interceptor) still works with the new data and works with fake/null initial data. The only way you can be sure of this, is by trying. Let me know! :)

--

--

No responses yet