projects/maplander/core/src/lib/network/network.module.ts
Static forRoot |
forRoot()
|
Returns :
ModuleWithProviders
|
/*
* Copyright (C) MapLander S de R.L de C.V - All Rights Reserved
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
*
*/
import {APP_INITIALIZER, ModuleWithProviders, NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {NetworkService} from './network.service';
@NgModule({
imports: [
CommonModule
],
})
export class NetworkModule {
public static forRoot(): ModuleWithProviders {
return {
ngModule: NetworkModule,
providers: [
NetworkService,
{
provide: APP_INITIALIZER,
useFactory: networkInit,
multi: true,
deps: [NetworkService]
}
]
};
}
}
export function networkInit(service: NetworkService) {
const f = () => service.init();
return f;
}