From 31477dbf946283fbb52a7e434174f23fc4e4a0ca Mon Sep 17 00:00:00 2001 From: volkanunsal Date: Sun, 4 May 2014 19:04:51 -0400 Subject: [PATCH 1/4] Update Dispatcher.js I think Array.filter expects a boolean return value, am I correct? --- examples/todomvc-flux/js/dispatcher/Dispatcher.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/todomvc-flux/js/dispatcher/Dispatcher.js b/examples/todomvc-flux/js/dispatcher/Dispatcher.js index f3b4f9838b7..6cfa5d9d680 100644 --- a/examples/todomvc-flux/js/dispatcher/Dispatcher.js +++ b/examples/todomvc-flux/js/dispatcher/Dispatcher.js @@ -53,9 +53,9 @@ var _clearPromises = function() { * Used below in waitFor(). * @param {number} index The index within the _promises array */ -var _getPromise = function(index) { - return _promises[index]; -}; +var _checkPromise = function(_,j){ + return promiseIndexes.indexOf(j) !== -1; +} var Dispatcher = function() {}; Dispatcher.prototype = merge(Dispatcher.prototype, { @@ -116,7 +116,7 @@ Dispatcher.prototype = merge(Dispatcher.prototype, { * A more robust Dispatcher would issue a warning in this scenario. */ waitFor: function(/*array*/ promiseIndexes, /*function*/ callback) { - var selectedPromises = promiseIndexes.filter(_getPromise); + var selectedPromises = _promises.filter(_checkPromise) Promise.all(selectedPromises).then(callback); } From a7823a3624f722f5afdcb4c5c198114408f68b6b Mon Sep 17 00:00:00 2001 From: volkanunsal Date: Sun, 4 May 2014 19:08:46 -0400 Subject: [PATCH 2/4] Update Dispatcher.js --- examples/todomvc-flux/js/dispatcher/Dispatcher.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/todomvc-flux/js/dispatcher/Dispatcher.js b/examples/todomvc-flux/js/dispatcher/Dispatcher.js index 6cfa5d9d680..b157eeb3ea8 100644 --- a/examples/todomvc-flux/js/dispatcher/Dispatcher.js +++ b/examples/todomvc-flux/js/dispatcher/Dispatcher.js @@ -54,7 +54,7 @@ var _clearPromises = function() { * @param {number} index The index within the _promises array */ var _checkPromise = function(_,j){ - return promiseIndexes.indexOf(j) !== -1; + return _promises.indexOf(j) !== -1; } var Dispatcher = function() {}; From c81c07c816ba782d6e15c661ed512a35f6b26c1f Mon Sep 17 00:00:00 2001 From: volkanunsal Date: Sun, 4 May 2014 19:15:44 -0400 Subject: [PATCH 3/4] Update Dispatcher.js --- examples/todomvc-flux/js/dispatcher/Dispatcher.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/examples/todomvc-flux/js/dispatcher/Dispatcher.js b/examples/todomvc-flux/js/dispatcher/Dispatcher.js index b157eeb3ea8..c55335fa29e 100644 --- a/examples/todomvc-flux/js/dispatcher/Dispatcher.js +++ b/examples/todomvc-flux/js/dispatcher/Dispatcher.js @@ -49,14 +49,6 @@ var _clearPromises = function() { _promises = []; }; -/** - * Used below in waitFor(). - * @param {number} index The index within the _promises array - */ -var _checkPromise = function(_,j){ - return _promises.indexOf(j) !== -1; -} - var Dispatcher = function() {}; Dispatcher.prototype = merge(Dispatcher.prototype, { @@ -116,7 +108,7 @@ Dispatcher.prototype = merge(Dispatcher.prototype, { * A more robust Dispatcher would issue a warning in this scenario. */ waitFor: function(/*array*/ promiseIndexes, /*function*/ callback) { - var selectedPromises = _promises.filter(_checkPromise) + var selectedPromises = _promises.filter(function(_,j){return promiseIndexes.indexOf(j) !== -1;}) Promise.all(selectedPromises).then(callback); } From 035a648a2d3bc117d81a88c07641eb48f15fafb3 Mon Sep 17 00:00:00 2001 From: volkanunsal Date: Mon, 5 May 2014 12:20:25 -0400 Subject: [PATCH 4/4] Update Dispatcher.js --- examples/todomvc-flux/js/dispatcher/Dispatcher.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/todomvc-flux/js/dispatcher/Dispatcher.js b/examples/todomvc-flux/js/dispatcher/Dispatcher.js index c55335fa29e..7adf400245b 100644 --- a/examples/todomvc-flux/js/dispatcher/Dispatcher.js +++ b/examples/todomvc-flux/js/dispatcher/Dispatcher.js @@ -108,7 +108,9 @@ Dispatcher.prototype = merge(Dispatcher.prototype, { * A more robust Dispatcher would issue a warning in this scenario. */ waitFor: function(/*array*/ promiseIndexes, /*function*/ callback) { - var selectedPromises = _promises.filter(function(_,j){return promiseIndexes.indexOf(j) !== -1;}) + var selectedPromises = _promises.filter(function(/*object*/ _, /*number*/ j) { + return promiseIndexes.indexOf(j) !== -1; + }); Promise.all(selectedPromises).then(callback); }