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

Commit 86328fb

Browse files
committedMay 7, 2014
feat: improve countingZone and example
1 parent ba72f34 commit 86328fb

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed
 

‎counting-zone.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
Zone.countingZone = {
66

77
// setTimeout
8-
enqueueTask: function () {
8+
'+enqueueTask': function () {
99
this.data.count += 1;
1010
},
1111

1212
// fires when...
1313
// - clearTimeout
1414
// - setTimeout finishes
15-
dequeueTask: function () {
15+
'-dequeueTask': function () {
1616
this.data.count -= 1;
1717
},
1818

19-
afterTask: function () {
19+
'+afterTask': function () {
2020
if (this.data.count === 0 && !this.data.flushed) {
2121
this.data.flushed = true;
2222
this.run(this.onFlush);

‎example/counting.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,20 @@ <h1>Counting Pending Tasks</h1>
2828
*/
2929
var myCountingZone = zone.fork(Zone.countingZone).fork({
3030
'+onZoneCreated': function () {
31-
Zone.countingZone.start || (Zone.countingZone.start = Date.now());
31+
this.data.start || (this.data.start = Date.now());
3232
this.print();
3333
},
3434
'-afterTask': function (delegate) {
3535
this.print();
3636
},
3737
'+reset': function (delegate) {
38-
Zone.countingZone.start = 0;
38+
this.data.start = 0;
3939
},
4040
print: function () {
4141
counter = this.counter();
4242
output.innerHTML = counter ?
4343
'pending task count: ' + counter :
44-
' DONE! ' + (Date.now() - Zone.countingZone.start)/1000 + 's';
44+
' DONE! ' + (Date.now() - this.data.start)/1000 + 's';
4545
}
4646
});
4747

0 commit comments

Comments
 (0)
This repository has been archived.