| Index: third_party/pkg/angular/lib/core/zone.dart
|
| ===================================================================
|
| --- third_party/pkg/angular/lib/core/zone.dart (revision 33054)
|
| +++ third_party/pkg/angular/lib/core/zone.dart (working copy)
|
| @@ -1,8 +1,7 @@
|
| part of angular.core;
|
|
|
| typedef void ZoneOnTurn();
|
| -typedef void ZoneOnError(dynamic error, dynamic stacktrace,
|
| - LongStackTrace longStacktrace);
|
| +typedef void ZoneOnError(dynamic error, dynamic stacktrace, LongStackTrace longStacktrace);
|
|
|
| /**
|
| * Contains the locations of runAsync calls across VM turns.
|
| @@ -15,11 +14,12 @@
|
| LongStackTrace(this.reason, this.stacktrace, this.parent);
|
|
|
| toString() {
|
| - List<String> frames = '${this.stacktrace}'.split('\n')
|
| - .where((frame) =>
|
| - frame.indexOf('(dart:') == -1 && // skip dart runtime libs
|
| - frame.indexOf('(package:angular/zone.dart') == -1 // skip angular zone
|
| - ).toList()..insert(0, reason);
|
| + List<String> frames = '${this.stacktrace}'.split('\n');
|
| + frames = frames.where((frame) {
|
| + return frame.indexOf('(dart:') == -1 && // skip dart runtime libs
|
| + frame.indexOf('(package:angular/zone.dart') == -1; // skip angular zone
|
| + }).toList();
|
| + frames.insert(0, reason);
|
| var parent = this.parent == null ? '' : this.parent;
|
| return '${frames.join("\n ")}\n$parent';
|
| }
|
| @@ -29,13 +29,8 @@
|
| * A better zone API which implements onTurnDone.
|
| */
|
| class NgZone {
|
| - final async.Zone _outerZone;
|
| - async.Zone _zone;
|
| -
|
| - NgZone()
|
| - : _outerZone = async.Zone.current
|
| - {
|
| - _zone = _outerZone.fork(specification: new async.ZoneSpecification(
|
| + NgZone() {
|
| + _zone = async.Zone.current.fork(specification: new async.ZoneSpecification(
|
| run: _onRun,
|
| runUnary: _onRunUnary,
|
| scheduleMicrotask: _onScheduleMicrotask,
|
| @@ -43,6 +38,7 @@
|
| ));
|
| }
|
|
|
| + async.Zone _zone;
|
|
|
| List _asyncQueue = [];
|
| bool _errorThrownFromOnRun = false;
|
| @@ -57,36 +53,42 @@
|
| rethrow;
|
| } finally {
|
| _runningInTurn--;
|
| - if (_runningInTurn == 0) _finishTurn(zone, delegate);
|
| + if (_runningInTurn == 0)
|
| + _finishTurn(zone, delegate);
|
| }
|
| }
|
| // Called from the parent zone.
|
| - _onRun(async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn()) =>
|
| - _onRunBase(self, delegate, zone, () => delegate.run(zone, fn));
|
| + _onRun(async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn()) {
|
| + return _onRunBase(self, delegate, zone, () => delegate.run(zone, fn));
|
| + }
|
|
|
| - _onRunUnary(async.Zone self, async.ZoneDelegate delegate, async.Zone zone,
|
| - fn(args), args) =>
|
| - _onRunBase(self, delegate, zone, () => delegate.runUnary(zone, fn, args));
|
| + _onRunUnary(async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn(args), args) {
|
| + return _onRunBase(self, delegate, zone, () => delegate.runUnary(zone, fn, args));
|
| + }
|
|
|
| - _onScheduleMicrotask(async.Zone self, async.ZoneDelegate delegate,
|
| - async.Zone zone, fn()) {
|
| + _onScheduleMicrotask(async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn()) {
|
| _asyncQueue.add(() => delegate.run(zone, fn));
|
| - if (_runningInTurn == 0 && !_inFinishTurn) _finishTurn(zone, delegate);
|
| + if (_runningInTurn == 0 && !_inFinishTurn) {
|
| + _finishTurn(zone, delegate);
|
| + }
|
| }
|
|
|
| - _uncaughtError(async.Zone self, async.ZoneDelegate delegate, async.Zone zone,
|
| - e, StackTrace s) {
|
| - if (!_errorThrownFromOnRun) onError(e, s, _longStacktrace);
|
| + _uncaughtError(async.Zone self, async.ZoneDelegate delegate, async.Zone zone, e, StackTrace s) {
|
| + if (!_errorThrownFromOnRun) {
|
| + onError(e, s, _longStacktrace);
|
| + }
|
| _errorThrownFromOnRun = false;
|
| }
|
|
|
| var _inFinishTurn = false;
|
| _finishTurn(zone, delegate) {
|
| - if (_inFinishTurn) return;
|
| + if (_inFinishTurn) {
|
| + return;
|
| + }
|
| _inFinishTurn = true;
|
| try {
|
| // Two loops here: the inner one runs all queued microtasks,
|
| - // the outer runs onTurnDone (e.g. scope.digest) and then
|
| + // the outer runs onTurnDone (e.g. scope.$digest) and then
|
| // any microtasks which may have been queued from onTurnDone.
|
| do {
|
| while (!_asyncQueue.isEmpty) {
|
| @@ -131,9 +133,7 @@
|
| }
|
|
|
| _getStacktrace() {
|
| - try {
|
| - throw [];
|
| - } catch (e, s) {
|
| + try { throw []; } catch (e, s) {
|
| return s;
|
| }
|
| }
|
| @@ -146,22 +146,6 @@
|
| */
|
| run(body()) => _zone.run(body);
|
|
|
| - /**
|
| - * Allows one to escape the auto-digest mechanism of Angular.
|
| - *
|
| - * myFunction(NgZone zone, Element element) {
|
| - * element.onClick.listen(() {
|
| - * // auto-digest will run after element click.
|
| - * });
|
| - * zone.runOutsideAngular(() {
|
| - * element.onMouseMove.listen(() {
|
| - * // auto-digest will NOT run after mouse move
|
| - * });
|
| - * });
|
| - * }
|
| - */
|
| - runOutsideAngular(body()) => _outerZone.run(body);
|
| -
|
| assertInTurn() {
|
| assert(_runningInTurn > 0 || _inFinishTurn);
|
| }
|
|
|