Skip to content

Instantly share code, notes, and snippets.

@wKoza

wKoza/angular.ts Secret

Created February 21, 2017 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wKoza/fe45d504dbef6b83a93c756002f49af8 to your computer and use it in GitHub Desktop.
Save wKoza/fe45d504dbef6b83a93c756002f49af8 to your computer and use it in GitHub Desktop.
constructor(@Inject(APP_INITIALIZER) @Optional() appInits: (() => any)[]) {
const asyncInitPromises: Promise<any>[] = [];
if (appInits) {
for (let i = 0; i < appInits.length; i++) {
const initResult = appInits[i]();
if (isPromise(initResult)) {
asyncInitPromises.push(initResult);
}
}
}
this._donePromise = Promise.all(asyncInitPromises).then(() => { this._done = true; });
if (asyncInitPromises.length === 0) {
this._done = true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment