-
Notifications
You must be signed in to change notification settings - Fork 149
collection store sugar #31
Copy link
Copy link
Open
Description
Some sugar for simple stores. It implements handleAdd, handleRemove, handleEmpty, getState, emptyWhere, setCollectionName.
var TodoStore = Fluxxor.createCollectionStore({
actions: {
"ADD_TODO": "handleAdd",
"TOGGLE_TODO": "handleToggleTodo",
"CLEAR_TODOS": "handleClear"
},
initialize: function() {
// provide the property name to fluxxor
this.setCollectionName("todos");
},
handleToggleTodo: function(payload) {
payload.todo.complete = !payload.todo.complete;
this.emit("change");
},
handleClear: function() {
this.removeWhere(function(todo){
return todo.complete;
});
this.emit("change");
},
});Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels