Created
April 24, 2017 14:36
-
-
Save mushfiqweb/3ca4dc3ed955a937e54e8ff0cd470457 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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