You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes you may want to have an async APP_INITIALIZER that needs to be resolved before bootstrapping. For example in a WebWorker you may want to receive some values from the UI (such as the browser location or history) before the app bootstraps. This is distinct from bootstrapping with asyncApplication because the DI providers are not themselves asynchronous, but rather some async work must be done after the providers are set up.
Angular will check the results of app initializers, collect all the promises, and wait for them to be resolved before resolving the application ref promise.
Angular will throw if an initializer returned a promise when application was used instead of asyncApplication.
Option 2
Another option would be to do the following:
function funcReturningAPromise:Promise() {...}
let appRef = platform(MY_PLATFORM).application([platform(APP_INITIALIZER, {useFactory: () => funcReturningAPromise})]);
appRef.get(APP_INITIALIZERS_COMPLETED).then(_ => {
});
This would work with both application and asyncApplication.
I also think Option 1 is cleaner. I'm happy to go ahead and implement it if you want. I think if we do option 1 we should allow people to pass in null as the first argument to asyncApplication as well as a function.
Activity
vsavkin commentedon Dec 16, 2015
Option 1
We can support it as follows:
applicationwas used instead ofasyncApplication.Option 2
Another option would be to do the following:
This would work with both
applicationandasyncApplication.I think Option 1 is cleaner.
jteplitz commentedon Dec 16, 2015
I also think Option 1 is cleaner. I'm happy to go ahead and implement it if you want. I think if we do option 1 we should allow people to pass in
nullas the first argument toasyncApplicationas well as a function.8 remaining items
feat(core/application_ref): Allow asyncronous app initializers.
angular-automatic-lock-bot commentedon Sep 7, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.