Skip to content

Instantly share code, notes, and snippets.

@dpalita
Last active August 2, 2018 20:18
Show Gist options
  • Save dpalita/4e23765d38d63f28324166fa68730124 to your computer and use it in GitHub Desktop.
Save dpalita/4e23765d38d63f28324166fa68730124 to your computer and use it in GitHub Desktop.
Provide promises to the angular APP_INITIALYZER to put application initialization on hold
export function accountReducerBootstrapFactory(reducer: AccountReducer) {
// bootstrap() returns a Promise
return () => reducer.bootstrap()
}
@NgModule({
...
providers: [
{
provide: APP_INITIALIZER,
deps: [AccountReducer],
multi: true,
useFactory: accountReducerBootstrapFactory
}
]
...
})
export class AccountModule {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment