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

Commit 32566cc

Browse files
vicbchirayuk
authored andcommitted
refactor(zone): add return types & doc
Closes #1073
1 parent 82ca6ba commit 32566cc

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
@@ -88,7 +88,8 @@ class VmTurnZone {
8888
bool _errorThrownFromOnRun = false;
8989

9090
var _currentlyInTurn = false;
91-
_onRunBase(async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn()) {
91+
92+
dynamic _onRunBase(async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn()) {
9293
_runningInTurn++;
9394
try {
9495
if (!_currentlyInTurn) {
@@ -105,28 +106,29 @@ class VmTurnZone {
105106
if (_runningInTurn == 0) _finishTurn(zone, delegate);
106107
}
107108
}
109+
108110
// Called from the parent zone.
109-
_onRun(async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn()) =>
111+
dynamic _onRun(async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn()) =>
110112
_onRunBase(self, delegate, zone, () => delegate.run(zone, fn));
111113

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

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

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

128129
var _inFinishTurn = false;
129-
_finishTurn(zone, delegate) {
130+
131+
void _finishTurn(zone, delegate) {
130132
if (_inFinishTurn) return;
131133
_inFinishTurn = true;
132134
try {
@@ -218,15 +220,27 @@ class VmTurnZone {
218220

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

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

0 commit comments

Comments
 (0)