I'm using ngrx/data 14 and Angular 14. I have built a custom module that I load in my app.module.ts file like so
@NgModule({
declarations: [
AppComponent
],
imports: [
...
AppRoutingModule,
MyCustomModule,
...
],
providers: [
...
],
bootstrap: [AppComponent]
})
export class AppModule { }
The custom module is defined this way
export function initialize(appService: AppService){
console.log("in initialize");
return () => appService.load();
}
...
@NgModule({
declarations: [
...
],
imports: [
...
],
exports: [
...
],
providers: [
{
provide: APP_INITIALIZER,
useFactory: initialize,
deps: [
AppService
],
multi: true
},
...
]
})
export class MyCustomModule {
constructor(entityDataService: EntityDataService, myObjectDataService: MyObjectDataService) {
console.log("called from module");
entityDataService.registerService('MyObject', myObjectDataService);
}
}
The problem is, I notice that the module constructor is run before the "initialize" method (I can see the console.log "called from module" is called before the "in initialize" statement within the "initialize" method. My question is, how or where do I put code that will initialize prior to my module getting instantiated?