Skip to content

Instantly share code, notes, and snippets.

@Abhinay-g
Last active December 13, 2018 10:37
Show Gist options
  • Save Abhinay-g/cd3c60fda7fd4839c5408c102111cd5c to your computer and use it in GitHub Desktop.
Save Abhinay-g/cd3c60fda7fd4839c5408c102111cd5c to your computer and use it in GitHub Desktop.
Zone JS
So what are Zones ????
>Zones is a new mechanism that helps developers work with [[ multiple logically-connected ]] async operations.
>Zones associate each async operation with a zone.
>A zone is an execution context that persists across async tasks, and allows the creator of the zone
to observe and control execution of the code within the zone.
Okay , but what could be the advantage of this ??
> We can Associate some [[data]] with zone, which can be accessed by all [[async]] code registered with that Zone
> Also It can handle Uncaught Error Or Unhandled REJECTED promises.
**Important
Let’s do an experiment. Go and take your favorite Angular 2 app, and don’t include zone.js. See what happens, I’ll wait here.
Notice anything interesting? None of the bindings are working!
In AngularThe Application subscribes to zone’s [[onTurnDone]] event,
which, if we do some more digging, calls [[tick]], which actually calls all of the change detectors.
So, without zones, we don’t get any change detection, so we don’t get any of the nice UI updates that we’d expect!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment