From e58899cdff9184890eab30b5fc67ffff774e7162 Mon Sep 17 00:00:00 2001 From: Ben Alpert Date: Tue, 20 May 2014 17:09:05 -0700 Subject: [PATCH] Make promise selection logic clearer --- examples/todomvc-flux/js/dispatcher/Dispatcher.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/todomvc-flux/js/dispatcher/Dispatcher.js b/examples/todomvc-flux/js/dispatcher/Dispatcher.js index 7adf400245b3..c1f8f8b0cc8f 100644 --- a/examples/todomvc-flux/js/dispatcher/Dispatcher.js +++ b/examples/todomvc-flux/js/dispatcher/Dispatcher.js @@ -108,8 +108,8 @@ 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(/*object*/ _, /*number*/ j) { - return promiseIndexes.indexOf(j) !== -1; + var selectedPromises = promiseIndexes.map(function(idx) { + return _promises[idx]; }); Promise.all(selectedPromises).then(callback); }