Commit 2528e217 authored by Gilad Peleg's avatar Gilad Peleg

reduce redundant filter & without syntax

parent 81d044dc
...@@ -7,21 +7,17 @@ define([ ...@@ -7,21 +7,17 @@ define([
], function (Backbone, Todo) { ], function (Backbone, Todo) {
'use strict'; 'use strict';
function isCompleted(todo) {
return todo.get('completed');
}
return Backbone.Collection.extend({ return Backbone.Collection.extend({
model: Todo, model: Todo,
localStorage: new Backbone.LocalStorage('todos-backbone'), localStorage: new Backbone.LocalStorage('todos-backbone'),
getCompleted: function () { getCompleted: function () {
return this.filter(isCompleted); return this.where({completed:true});
}, },
getActive: function () { getActive: function () {
return this.reject(isCompleted); return this.where({completed:false});
}, },
comparator: function (todo) { comparator: function (todo) {
......
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