import { NgModule, APP_INITIALIZER, Type } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { UCAP_NATIVE_SERVICE, NativeService } from '@ucap-webmessenger/native'; import { RESOLVERS } from './resolvers'; import { SERVICES } from './services'; import { AppService } from './services/app.service'; import { environment } from '../environments/environment'; import { BrowserNativeService } from '@ucap-webmessenger/native-browser'; import { ElectronNativeService } from '@ucap-webmessenger/native-electron'; export function initializeApp( appService: AppService, nativeService: NativeService ) { return (): Promise => { return appService.postInit(); }; } @NgModule({ imports: [], exports: [], providers: [ { provide: UCAP_NATIVE_SERVICE, // useFactory: nativeServiceFactory, useClass: 'browser' === environment.runtime ? BrowserNativeService : ElectronNativeService, deps: [HttpClient] }, ...SERVICES, ...RESOLVERS, { provide: APP_INITIALIZER, useFactory: initializeApp, deps: [AppService, UCAP_NATIVE_SERVICE], multi: true } ] }) export class AppProviderModule {}