var Todo = Y.Base.create('Todo', Y.Model, [], {
// Toggle the completed state of the Todo.
toggle: function () {
this.save({completed: !this.get('completed')});
},
// Destroy this Todo and remove it from our sync layer.
clear: function () {
this.destroy({remove: true});
}
});
var Todo = Y.Base.create('Todo', Y.Model, [Y.ModelSync.Local], {
// Set the key in LocalStorage that we save this model type in
root: 'todos',
// Toggle the completed state of the Todo.
toggle: function () {
this.save({completed: !this.get('completed')});
},
// Destroy this Todo and remove it from our sync layer.
clear: function () {
this.destroy({remove: true});
}
});
var Todo = Y.Base.create('Todo', Y.Model, [Y.ModelSync.REST], {
// Set the URL that we map CRUD to REST to in our REST API.
// In this case, we send our HTTP requests to '/todos/:id'
root: 'todos',
// Toggle the completed state of the Todo.
toggle: function () {
this.save({completed: !this.get('completed')});
},
// Destroy this Todo and remove it from our sync layer.
clear: function () {
this.destroy({remove: true});
}
});
var Todo = Y.Base.create('Todo', Y.Model, [Y.ModelSync.Socket], {
// Our Model will now listen for Socket events with a 'todos/:id' header
root: 'todos',
// Toggle the completed state of the Todo.
toggle: function () {
this.save({completed: !this.get('completed')});
},
// Destroy this Todo and remove it from our sync layer.
clear: function () {
this.destroy({remove: true});
}
});