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
Usage of ngZone.run for new async apis that zone.js hasn't pathced #44714
Comments
|
I believe you are correct; |
|
@JoostK Thanks for your reply, it's been confusing me for two days now. I dug deep into zone.js, but still didn't find out how |
`NgZone.run` needs to be within the async closure, not around its registration, refer to: angular#44714
Alan-LOL
mentioned this issue
|
This issue can be closed, right? The docs are fixed as far as I can tell and the PR was closed too. |
|
Indeed! |
|
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. |


Description
Is this demo correct? how ngZone knows when to update the view as zone.js hasn't patch
someNewAsyncAPIWhat is the affected URL?
https://angular.io/guide/zone#ngzone-run-and-runoutsideofangular
Please provide the steps to reproduce the issue
No response
Please provide the expected behavior vs the actual behavior you encountered
I think the demo code should be updated as below:
export class AppComponent implements OnInit { constructor(private ngZone: NgZone) {} ngOnInit() { // New async API is not handled by Zone, so you need to // use ngZone.run() to make the asynchronous operation in the Angular zone // and trigger change detection automatically. - this.ngZone.run(() => { someNewAsyncAPI(() => { + this.ngZone.run(() => { // update the data of the component + }); }); - }); } }Please provide a screenshot if possible
No response
Please provide the exception or error you saw
No response
Is this a browser-specific issue? If so, please specify the device, browser, and version.
No response
The text was updated successfully, but these errors were encountered: