import { NgModule, APP_INITIALIZER } from '@angular/core';
import { HttpClientModule } from '@angular/common/http';

import { AppConfigService } from './app-config.service';


export function initAppConfig(appConfigService: AppConfigService) {
  return () => appConfigService.load();
}


@NgModule({
  imports: [
    HttpClientModule
  ],
  providers: [
    AppConfigService,
    {
      provide: APP_INITIALIZER,
      useFactory: initAppConfig,
      deps: [
        AppConfigService
      ],
      multi: true
    }
  ]
})
export class AppConfigModule { }
