Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit 2acaa10

Browse files
vicbchirayuk
authored andcommitted
refactor(zone): add return types & doc
Closes #1073
1 parent eee14d0 commit 2acaa10

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

lib/core/zone.dart

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ class VmTurnZone {
8787
bool _errorThrownFromOnRun = false;
8888

8989
var _currentlyInTurn = false;
90-
_onRunBase(async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn()) {
90+
91+
dynamic _onRunBase(async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn()) {
9192
_runningInTurn++;
9293
try {
9394
if (!_currentlyInTurn) {
@@ -104,28 +105,29 @@ class VmTurnZone {
104105
if (_runningInTurn == 0) _finishTurn(zone, delegate);
105106
}
106107
}
108+
107109
// Called from the parent zone.
108-
_onRun(async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn()) =>
110+
dynamic _onRun(async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn()) =>
109111
_onRunBase(self, delegate, zone, () => delegate.run(zone, fn));
110112

111-
_onRunUnary(async.Zone self, async.ZoneDelegate delegate, async.Zone zone,
112-
fn(args), args) =>
113+
dynamic _onRunUnary(async.Zone self, async.ZoneDelegate delegate, async.Zone zone,
114+
fn(args), args) =>
113115
_onRunBase(self, delegate, zone, () => delegate.runUnary(zone, fn, args));
114116

115-
_onScheduleMicrotask(async.Zone self, async.ZoneDelegate delegate,
116-
async.Zone zone, fn()) {
117+
void _onScheduleMicrotask(async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn()) {
117118
onScheduleMicrotask(() => delegate.run(zone, fn));
118119
if (_runningInTurn == 0 && !_inFinishTurn) _finishTurn(zone, delegate);
119120
}
120121

121-
_uncaughtError(async.Zone self, async.ZoneDelegate delegate, async.Zone zone,
122-
e, StackTrace s) {
122+
void _uncaughtError(async.Zone self, async.ZoneDelegate delegate, async.Zone zone,
123+
e, StackTrace s) {
123124
if (!_errorThrownFromOnRun) onError(e, s, _longStacktrace);
124125
_errorThrownFromOnRun = false;
125126
}
126127

127128
var _inFinishTurn = false;
128-
_finishTurn(zone, delegate) {
129+
130+
void _finishTurn(zone, delegate) {
129131
if (_inFinishTurn) return;
130132
_inFinishTurn = true;
131133
try {
@@ -217,15 +219,27 @@ class VmTurnZone {
217219

218220
/**
219221
* Runs [body] in the inner zone and returns whatever it returns.
222+
*
223+
* In a typical app where the inner zone is the Angular zone, this allows one to make use of the
224+
* Angular's auto digest mechanism.
225+
*
226+
* VmTurnZone zone = <ref to app.zone>;
227+
*
228+
* void functionCalledFromJS() {
229+
* zone.run(() {
230+
* // auto-digest will run after this function is called from JS
231+
* })
232+
* }
220233
*/
221234
dynamic run(body()) => _innerZone.run(body);
222235

223236
/**
224237
* Runs [body] in the outer zone and returns whatever it returns.
225-
* In a typical app where the inner zone is the Angular zone, this allows
226-
* one to escape Angular's auto-digest mechanism.
227238
*
228-
* myFunction(VmTurnZone zone, Element element) {
239+
* In a typical app where the inner zone is the Angular zone, this allows one to escape Angular's
240+
* auto-digest mechanism.
241+
*
242+
* void myFunction(VmTurnZone zone, Element element) {
229243
* element.onClick.listen(() {
230244
* // auto-digest will run after element click.
231245
* });

0 commit comments

Comments
 (0)