liveBook · Manning

NgZone

As explained in Modern Angular

NgZone is an Angular injectable wrapper that exposes APIs for interacting with Zone.js execution contexts.

NgZone is an Angular injectable wrapper around Zone.js execution contexts. Its APIs can support existing Angular applications, but some stability-related APIs become incompatible with zoneless change detection. section 10.3.5

When preparing an application for zoneless change detection:

  • Remove uses of NgZone.onMicrotaskEmpty, NgZone.onUnstable, NgZone.isStable, and NgZone.onStable; their tasks become unnecessary with zoneless operation. section 10.3.5
  • Retain NgZone.run and NgZone.runOutsideAngular, which remain compatible with zoneless applications. section 10.3.5
  • Check server-side rendering separately because SSR uses application stability to determine when rendered output can be serialized. section 10.3.5

How Modern Angular covers it

How deep it goes
Identifies compatible and incompatible NgZone APIs and flags SSR stability concerns without detailing Zone.js internals.
Examples
Uses NgZone.onStable, NgZone.isStable, NgZone.run, and NgZone.runOutsideAngular as migration examples.
What you can do after
Evaluate NgZone usage and remove stability-event dependencies before adopting zoneless change detection.
How it connects
Connects NgZone with Zone.js, zoneless change detection, and Angular server-side rendering.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern Angular. The section links point to the parts of the book it draws on.