In the previous article, we talked about the basic
monkey-patch mechanism of Zone.js, In this article, we will go deep into another very important concept of Zone.js, which is async operations lifecycle hooks, with those hooks, Zone can monitor and intercept all lifecycles of async operations.
It is easy to explain with code sample.
This is a very simple code sample to explain how Zone.js intercept the lifecycle events of
setTimeout, here we fork a new zone named
zone with three callbacks.
onScheduleTask, this callback will be called before async operation is
scheduled, that means when the async operation is about to sent to browser(or NodeJS) to be scheduled to run later. …
From two years ago, I began to contribute to
Zone.js , and now I am the collaborator and basically take charge of everything of
Zone.js is a very powerful tool, I really love it and want to introduce this library to more users. So I will write a series of articles to introduce how
Zone.js works under the hood, and how to use
Zone.js in real life project.