Skip to content
Browse files

This does NOT use the .all, but did not work at all.

  • Loading branch information...
1 parent 1b562a6 commit 69db89b95bfd87437c30c76f763199dc53530fad @simkimsia committed
Showing with 12 additions and 3 deletions.
  1. +12 −3 testqjs.html
View
15 testqjs.html
@@ -50,10 +50,19 @@
SIZES['Common'] = {'ratio' : 0.65};
function traverseFiles() {
+ // collect all the promises
+ // of the traversed files undergoing calculateRatio
+ var promises = [];
+ var to_go = pages.length;
for (var i=0, l=pages.length; i<l; i++) {
- getSizeSettingsFromPage(pages[i], calculateRatio);
+ getSizeSettingsFromPage(pages[i], calculateRatio).then(function(value){
+ to_go--;
+ if(to_go == 0){
+ checkWhenReady();
+ }
+ });
}
- checkWhenReady(); // this does NOT work.
+ //Q.all(promises).then(function(value){ checkWhenReady() });
}
function getSizeSettingsFromPage(file, whenReady) {
@@ -93,7 +102,7 @@
}
pageSizes.add(filename, object);
- checkWhenReady(); // this works but it is not ideal. I prefer to call this method AFTER all the `pages` have undergone calculateRatio
+
}
function checkWhenReady() {

0 comments on commit 69db89b

Please sign in to comment.
Something went wrong with that request. Please try again.