npm install
npm run serve
npm run build
npm run lint
One of the most potentially confusing parts is the tangle of standard and custom events we've used to trigger all the interactivity in our app. To understand this better, it is a good idea to write out a flow chart, description, or diagram of what events are emitted where, where they are being listened for, and what happens as a result of them firing.
For example:
App.vue
<to-do-form> listens for:
todo-addedevent emitted by theonSubmit()method inside theToDoFormcomponent when the form is submitted. Result:addToDo()method invoked to add new todo item to theToDoItemsarray.
<to-do-item> listens for:
checkbox-changedevent emitted by the checkbox<input>inside theToDoItemcomponent when it is checked or unchecked. Result:updateDoneStatus()method invoked to update done status of associated todo item.item-deletedevent emitted by thedeleteToDo()method inside theToDoItemcomponent when the "Delete" button is pressed. Result:deleteToDo()method invoked to delete associated todo item.item-editedevent emitted by theitemEdited()method inside theToDoItemcomponent when theitem-editedevent emitted by theonSubmit()method inside theToDoItemEditFormhas been successfully listened for. Yes, this is a chain of two differentitem-editevents! Result:editToDo()method invoked to update label of associated todo item.
ToDoForm.vue
<form> listens for submit event.
Result: onSubmit() method is invoked, which checks that the new label is not empty, then emits the todo-added event (which is then listened for inside App.vue, see above), and finally clears the new label <input>.
ToDoItem.vue
checkbox <input> listens for change event.
Result: checkbox-changed event emitted when the checkbox is checked/unchecked (which is then listened for inside App.vue; see above).
"Edit" <button> listens for click event.
Result: toggleToItemEditForm() method is invoked, which toggles this.isEditing to true, which in turn displays the todo item's edit form on re-render.
"Delete" <button> listens for click event.
Result: deleteToDo() method is invoked, which emits the item-deleted event (which is then listened for inside App.vue; see above)
<to-do-item-edit-form> listens for:
item-editedevent emitted by theonSubmit()method inside theToDoItemEditFormcomponent when the form is successfully submitted. Result:itemEdited()method is invoked, which emits theitem-editedevent (which is then listened for insideApp.vue, see above), and setsthis.isEditingback tofalse, so that the edit form is no longer shown on re-render.edit-cancelledevent emitted by theonCancel()method inside theToDoItemEditFormcomponent when the "Cancel" button is clicked. Result:editCancelled()method is invoked, which setsthis.isEditingback tofalse, so that the edit form is no longer shown on re-render.
ToDoItemEditForm.vue
<form> listens for submit event.
Result: onSubmit() method is invoked, which checks to see if the new label value is not blank, and not the same as the old one, and if so emits the item-edited event (which is then listened for inside ToDoItem.vue, see above).
"Cancel" <button> listens for click event.
Result: onCancel() method is invoked, which emits the edit-cancelled event (which is then listened for inside ToDoItem.vue, see above).