Last active
November 2, 2018 10:33
-
-
Save LayZeeDK/f7c90639ec6fb1b326af25297c29236a to your computer and use it in GitHub Desktop.
TypeScript: Edit todo item view
This file contains hidden or 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
class EditTodoItemView { | |
todoItem: TodoItem; | |
onInitialize(id: string): Promise<void> { | |
return this.readTodoItem(id) | |
.then(todoItem => this.todoItem = todoItem) | |
.then(() => undefined); | |
} | |
readTodoItem(id: string): Promise<TodoItem> { | |
return fetch("/todo/" + id) | |
.then((response: HttpResponse) => response.json()); | |
} | |
saveTodoItem(): Promise<void> { | |
return this.todoItem.save(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment