From 31477dbf946283fbb52a7e434174f23fc4e4a0ca Mon Sep 17 00:00:00 2001 From: volkanunsal Date: Sun, 4 May 2014 19:04:51 -0400 Subject: [PATCH] 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 f3b4f9838b..6cfa5d9d68 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); }