Skip to content

Instantly share code, notes, and snippets.

@LayZeeDK
Last active November 2, 2018 10:33
Show Gist options
  • Save LayZeeDK/f7c90639ec6fb1b326af25297c29236a to your computer and use it in GitHub Desktop.
Save LayZeeDK/f7c90639ec6fb1b326af25297c29236a to your computer and use it in GitHub Desktop.
TypeScript: Edit todo item view
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