Skip to content

Instantly share code, notes, and snippets.

@wullemsb
Created September 19, 2018 05:53
import { NgModule, APP_INITIALIZER } from '@angular/core';
import { HttpClientModule, HttpClient } from "@angular/common/http";
import 'rxjs/add/operator/toPromise';
export function initializeApplication(httpClient: HttpClient): () => Promise<any> {
return (): Promise<any> => {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve();
}, 3000);
});
};
}
@NgModule({
imports: [HttpClientModule],
providers: [
{ provide: APP_INITIALIZER, useFactory: initializeApplication, deps: [HttpClient] multi: true }
]
})
export class AppModule { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment