Get zone-free window methods with Zone.js Get zone-free window methods with Zone.js typescript typescript

Get zone-free window methods with Zone.js


yes, basically the native method can be access by

target[Zone['__symbol__'](methodName)]

or target['zone_symbol'methodName]

such as

window['__zone_symbol__setTimeout']

and you can access NativePromise by

window['__zone_symbol__Promise']

I will make a list later.


I think that you need to leverage NgZone and its runOutsideAngular method for this. Here is a sample:

constructor(private ngZone:NgZone) {}setTimeout(() => {  this.ngZone.runOutsideAngular(() => {    // do something  });}, 1000);


Adding to the answer, the original methods can be reached with __zone_symbol__ prefix, as of Zone.js 0.6.12 (may be a subject to change).

I.e. window.__zone_symbol__setTimeout, etc.