Skip to content

Instantly share code, notes, and snippets.

@mushfiqweb
Created April 24, 2017 14:36
Show Gist options
  • Save mushfiqweb/3ca4dc3ed955a937e54e8ff0cd470457 to your computer and use it in GitHub Desktop.
Save mushfiqweb/3ca4dc3ed955a937e54e8ff0cd470457 to your computer and use it in GitHub Desktop.
State.on('todo:update', function( todo, text ){
// Setting the status to updating we can show
// a deleting message in the component.
var updated = todo.pivot().ui.set({ status: 'updating' });
// Emulate a server call
setTimeout( function(){
var todo = State.get().todos.find( updated );
// We need to pivot in the node to modify multiple children.
// Pivoting will make children changes return the updated
// todo instead the updated child.
todo.pivot()
.model.set({ title: text })
// We remove the loading message now
// when the todo has been updated.
.ui.set({ status: 'ready' })
;
}, lag);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment