projects/maplander/core/src/lib/router-loader/router-loader.module.ts
Static forRoot |
forRoot()
|
Returns :
ModuleWithProviders
|
import {APP_INITIALIZER, ModuleWithProviders, NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {LoaderService} from '../interceptors/loader/loader.service';
import {RouterLoaderService} from './router-loader.service';
@NgModule({
imports: [
CommonModule
],
declarations: []
})
export class RouterLoaderModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: RouterLoaderModule,
providers: [
LoaderService,
RouterLoaderService,
{
provide: APP_INITIALIZER,
useFactory: initRouterLoader,
multi: true,
deps: [RouterLoaderService]
}
]
};
}
}
export function initRouterLoader(service: RouterLoaderService) {
const f = () => service.start();
return f;
}