We know that in root module provider we can set an APP_INITIALIZER that bootstrap some dependencies in the backend and then loads the first component
{
provide: APP_INITIALIZER,
useFactory: configLoader,
multi: true,
deps: [ConfigService]
}
I will load my user configs before the app starts in the above way, but I want to do somehing more, like connect websocket before my app starts.
I know that I can do in in configLoader function that I wrote, that first load configs and then connect websocket in that configLoader function, but for some reasons, I can't do that right now, so I need do in in someway like this:
{
provide: APP_INITIALIZER,
useFactory: [configLoader, websocketLoader],
multi: true,
deps: [ConfigService, WebsocketService]
}
But unfortunately, it won't work. So is there any way to load multiple app initializers?
multi:trueallows creating as many providers as like under the same token. You may find the following articles helpful as well Hooking into the Angular bootstrap process and How to manually bootstrap an Angular application