-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(core): support APP_INITIALIZER work with observable #33222
feat(core): support APP_INITIALIZER work with observable #33222
Conversation
ac82f5b
to
fa6f57d
Compare
b77bf85
to
5253a23
Compare
92490df
to
da40ee2
Compare
cc @alxhub |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since toPromise
is being deprecated, maybe we need to use something like await lastValueFrom
?
We also need to update the doc here https://angular.io/guide/dependency-injection-providers |
Hi @vthinkxie, sorry we didn't have a chance to review your PR sooner. As Jia mentioned above, the Thank you. |
da40ee2
to
bb94e6b
Compare
Hi @JiaLiPassion @AndrewKushnir |
@vthinkxie just want to let you know that tests in Google's codebase went well, the PR was approved by all reviewers and it's ready for merge, so I'm adding it to the merge queue. Thanks for implementing this feature and addressing all the feedback 👍 |
Hi @AndrewKushnir and @JoostK thanks a lot for your review, looking forward to having this feature in the next angular version! |
Finally it came to an end! Nearly... |
…e-effects (#33222) Currently TestBed (both ViewEngine and Ivy) invoke `ApplicationInitStatus.runInitializers` as a part of the bootstrap process to mimic real bootstrap steps. This is problematic for the `ApplicationInitStatus` class tests since the `runInitializers` call performed by TestBed interfere with actual tests. This commit updates ApplicationInitStatus tests to interact with the class directly instead of relying on TestBed APIs to retrieve the class though DI. PR Close #33222
@vthinkxie Could you please tell me how to use this functionality? I now have this: I have angular version 12.0.0-next.5 installed, but it does not wait until the observable is resolved. The function authService.retrieveToken() does a http get call. Hope you can give a bit more explanation. Thanks! |
Hi @SandraVanDijk, could you please create a minimum repro using Stackblitz, so that we can have a look? Note: you could update package versions in the |
Hi @AndrewKushnir, thanks for your response. I tried to make a Stackblitz as requested, and I updated the packages.json as you told me. After I press save it did install packages and then it says "running ngcc", it doing that now for 2 hours. I never used this tool before, so not sure how to solve this. Is there maybe another way on how to share my code? |
You could also try to create a new app (using |
Hi @AndrewKushnir, thanks for that tip! While making a new repository I figured out what my mistake was. The function I was calling did not return an observable. So it made total sense APP_INILIALIZER did not wait. I also found today this documentation: https://dzhavat.github.io/2021/02/25/using-observable-in-app-initializer.html, maybe this helps somebody else. Thanks for your help! |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
close #15088
PR Checklist
Please check if your PR fulfills the following requirements:
Docs have been added / updated (for bug fixes / features)PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information