Commit 13e5e49e authored by Sindre Sorhus's avatar Sindre Sorhus

Merge pull request #777 from daleharvey/776

Close GH-776: Make sure updateCount works with async Stores
parents fe2f9ba0 896810e1
......@@ -199,16 +199,16 @@
* number of todos.
*/
Controller.prototype._updateCount = function () {
var todos = this.model.getCount();
this.view.render('updateElementCount', todos.active);
this.view.render('clearCompletedButton', {
completed: todos.completed,
visible: todos.completed > 0
});
this.model.getCount((function(todos) {
this.view.render('updateElementCount', todos.active);
this.view.render('clearCompletedButton', {
completed: todos.completed,
visible: todos.completed > 0
});
this.view.render('toggleAll', {checked: todos.completed === todos.total});
this.view.render('contentBlockVisibility', {visible: todos.total > 0});
this.view.render('toggleAll', {checked: todos.completed === todos.total});
this.view.render('contentBlockVisibility', {visible: todos.total > 0});
}).bind(this);
};
/**
......
......@@ -93,7 +93,7 @@
/**
* Returns a count of all todos
*/
Model.prototype.getCount = function () {
Model.prototype.getCount = function (callback) {
var todos = {
active: 0,
completed: 0,
......@@ -110,9 +110,8 @@
todos.total++;
});
callback(todos);
});
return todos;
};
// Export to window
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment