import { BrowserModule } from '@angular/platform-browser'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { APP_INITIALIZER, NgModule } from '@angular/core'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { CoreModule } from './core/core.module'; import { AppStarterService } from './app-starter.service'; import { ServiceWorkerModule } from '@angular/service-worker'; import { provideHttpClient, withFetch } from '@angular/common/http'; @NgModule({ declarations: [ AppComponent, ], imports: [ BrowserModule, BrowserAnimationsModule, CoreModule, AppRoutingModule, ServiceWorkerModule.register('ngsw-worker.js', { enabled: false, // Register the ServiceWorker as soon as the app is stable // or after 30 seconds (whichever comes first). registrationStrategy: 'registerWhenStable:30000' }), ], providers: [ AppStarterService, { provide: APP_INITIALIZER, useFactory: (appStarterService) => { return () => new Promise((resolve) => { appStarterService.start().subscribe(() => resolve()); }); }, deps: [AppStarterService], multi: true }, provideHttpClient(withFetch()), ], bootstrap: [ AppComponent, ], }) export class AppModule {}