Skip to content

Instantly share code, notes, and snippets.

@arqex
Created September 19, 2015 16:22
Show Gist options
  • Save arqex/1e8f859fa536ddc56047 to your computer and use it in GitHub Desktop.
Save arqex/1e8f859fa536ddc56047 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