runOutsideAngular<R> method

R runOutsideAngular<R>(
  1. R callback()
)

Executes and returns callback function synchronously outside this zone.

Typically, this API should be used when a high-frequency event such as a polling timer or mouse movement is being observed within callback, and for performance reasons you want to only react sometimes:

// Just an example, not ideal!
void example(NgZone zone) {
  zone.runOutsideAngular(() {
    Timer(Duration.zero, () {
      if (someOtherValue) {
        zone.run(() => computeSomething());
      }
    });
  });
}

Implementation

R runOutsideAngular<R>(R Function() callback) {
  return _outerZone.run(callback);
}