Wednesday, June 13, 2018


Once when I was last at Dell and I was taking a break from blogging, there was a random training on the zones associated with NgZone which I then never worked with. I scribbled all my notes down in a little notebook that I ended up throwing away and now I cannot remember what was discussed. This makes it look like a way to sandbox processes so that we do not kick off other watchers and update components and cause a performance problem. I wonder if this would even be needed if you have the OnPush ChangeDetectionStrategy afloat in prevalence. If you are using the Default ChangeDetectionStrategy and you normally don't have a problem in having the usual watchers running, but you also want to set up your own loop on a timer to manage some corny cartoon clock in the corner of the screen of something like that well I can see why you might not want that overhead adding to the rest of the overhead of the watchers by triggering change detection. The link I provide has this example;

this._ngZone.runOutsideAngular(() => {
   this._increaseProgress(() => {
// reenter the Angular zone and display done => { console.log('Outside Done!'); });


This code sits in a component and _ngZone is a variable declared at the constructor (as so many variables of Angular magic are) of type NgZone. _increaseProgress is a method that you might run in the sandbox, get it?

No comments:

Post a Comment