forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcounting-zone.js
More file actions
35 lines (29 loc) · 801 Bytes
/
counting-zone.js
File metadata and controls
35 lines (29 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
* See example/counting.html
*/
Zone['countingZoneSpec'] = {
name: 'counterZone',
// setTimeout
onScheduleTask: function (delegate, current, target, task) {
this.data.count += 1;
delegate.scheduleTask(target, task);
},
// fires when...
// - clearTimeout
// - setTimeout finishes
onInvokeTask: function (delegate, current, target, task, applyThis, applyArgs) {
delegate.invokeTask(target, task, applyThis, applyArgs);
this.data.count -= 1;
},
onHasTask: function (delegate, current, target, hasTask) {
if (this.data.count === 0 && !this.data.flushed) {
this.data.flushed = true;
target.run(this.onFlush);
}
},
counter: function () {
return this.data.count;
},
data: {count: 0, flushed: false},
onFlush: function () {},
};