![]() ![]() Now in this case, there exists no parent of childAZone which has interception defined, so it will simply execute this function. childAZone also follows the same process and sends this function to the closest parent which also defines the interception for any function. So childAZone also intercepts this helloFunction and logs “intercepted in childAZone before execution”. The closest parent which also defines interception for functions here is childAZone. It prints log “intercepted in childBZone before execution” in the console and then sends this helloFunction to the closest parent which also has defined interception for function executions. This function is then intercepted by childBZone since it defines interception for execution of any function as defined in it’s ZoneSpec while creating it. Then we’re defining a function helloFunction and executing it in childBZone. onInvoke where I am logging some messages before and after the execution of a function in each zone. 1, but while forking new zones, I have passed in one more value in ZoneSpec i.e. Here, I am creating the same hierarchy discussed in fig. ZoneTask has a member named type which can have a value of either microTask, macroTask or eventTask. MacroTask - setTimeout(), cleatTimeout(), setInterval()…….ZoneTask are classified into three types: This ZoneTask is responsible for storing the arguments passed during the invocation of setTimeout, the way of scheduling and invoking the setTimeout (or any other async API). This ZoneTask is an object which implements the Task interface. During initialization, zone.js creates a ZoneTask using setTimeout’s parameter and schedules it in the current Zone (more on it later). Let’s take the example of the setTimeout API. On the next line we redefine the behaviour of setTimeout where we can do anything we want and then call the original behaviour which we have stored in original and then return back the result.ĭuring initialization zone.js does the same process along with all the browser APIs. ![]() Here we are storing the existing behaviour of window’s setTimeout in original. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |