Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions examples/todomvc-flux/js/dispatcher/Dispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@ var _clearPromises = function() {
_promises = [];
};

/**
* Used below in waitFor().
* @param {number} index The index within the _promises array
*/
var _getPromise = function(index) {
return _promises[index];
};

var Dispatcher = function() {};
Dispatcher.prototype = merge(Dispatcher.prototype, {

Expand Down Expand Up @@ -116,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 = promiseIndexes.filter(_getPromise);
var selectedPromises = _promises.filter(function(/*object*/ _, /*number*/ j) {
return promiseIndexes.indexOf(j) !== -1;
});
Promise.all(selectedPromises).then(callback);
}

Expand Down