InterviewHubPRO
Section Overview
Q247

Question 247 of 283

Part 9: NgModules, Providers, NgZone & Injector Hierarchies (213 - 255)

87%
Angular & Signals (283 Qs)•Part 9: NgModules, Providers, NgZone & Injector Hierarchies (213 - 255)

What is a zone context?

Execution Context is an abstract concept that holds information about the environment within the current code being executed. A zone provides an execution context that persists across asynchronous operations is called as zone context. For example, the zone context will be same in both outside and inside setTimeout callback function,

js
zone.run(() => {
 // outside zone
 expect(zoneThis).toBe(zone);
 setTimeout(function() {
   // the same outside zone exist here
   expect(zoneThis).toBe(zone);
 });
});

The current zone is retrieved through Zone.current.