Skip to content

Commit

Permalink
Finish basic store example
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Richter committed Apr 11, 2018
1 parent 39dc345 commit 82527ea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/components/ListView/_ListView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import sweetalert from 'sweetalert'
import Todo from './Todo.vue'
import CreateTodo from './TodoCreate.vue'
import { mapState } from 'vuex'
import { mapState, mapMutations } from 'vuex'
// Todo: use absolute path src/ as root https://github.com/parcel-bundler/parcel/pull/850
import { TheHeader } from '../index.js'
Expand Down Expand Up @@ -80,6 +80,8 @@
},
methods: {
...mapMutations(['addTodo']),
deleteTodo(todo) {
sweetalert(
'Are you sure you want to delete that?', {
Expand Down Expand Up @@ -107,7 +109,9 @@
},
createTodo(newTodo) {
this.todos.push(newTodo)
this.addTodo(newTodo)
sweetalert('Success!', 'To-Do created!', 'success')
},
Expand Down
7 changes: 3 additions & 4 deletions src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ export default new Vuex.Store({
}],
},
mutations: {
// addTodo (state) {
// console.log('addTodo: %o', state)
// // state.todos
// },
addTodo (state, newTodo) {
state.todos.push(newTodo)
},
},
})

0 comments on commit 82527ea

Please sign in to comment.