File tree Expand file tree Collapse file tree 12 files changed +62
-42
lines changed
Expand file tree Collapse file tree 12 files changed +62
-42
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ export default {
4242 sendMessage (e ) {
4343 const text = e .target .value
4444 if (text .trim ()) {
45- this .$store .call (' sendMessage' , {
45+ this .$store .trigger (' sendMessage' , {
4646 text,
4747 thread: this .thread
4848 })
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ export default {
4040 },
4141 methods: {
4242 switchThread (id ) {
43- this .$store .call (' switchThread' , { id })
43+ this .$store .trigger (' switchThread' , { id })
4444 }
4545 }
4646}
Original file line number Diff line number Diff line change 1+ import 'babel-polyfill'
12import Vue from 'vue'
23import Counter from './Counter.vue'
34import store from './store'
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ export default {
3030 },
3131 methods: {
3232 checkout (products ) {
33- this .$store .call (' checkout' , products)
33+ this .$store .trigger (' checkout' , products)
3434 }
3535 }
3636}
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ export default {
2323 ' addToCart'
2424 ]),
2525 created () {
26- this .$store .call (' getAllProducts' )
26+ this .$store .trigger (' getAllProducts' )
2727 }
2828}
2929 </script >
Original file line number Diff line number Diff line change 1616 <input class =" toggle-all"
1717 type =" checkbox"
1818 :checked =" allChecked"
19- @change =" toggleAll(!allChecked)" >
19+ @change =" toggleAll({ done: !allChecked } )" >
2020 <ul class =" todo-list" >
2121 <todo v-for =" todo in filteredTodos" :todo =" todo" ></todo >
2222 </ul >
@@ -81,7 +81,7 @@ export default {
8181 addTodo (e ) {
8282 var text = e .target .value
8383 if (text .trim ()) {
84- this .$store .call (' addTodo' , text)
84+ this .$store .trigger (' addTodo' , { text } )
8585 }
8686 e .target .value = ' '
8787 },
Original file line number Diff line number Diff line change 44 <input class =" toggle"
55 type =" checkbox"
66 :checked =" todo.done"
7- @change =" toggleTodo(todo)" >
7+ @change =" toggleTodo({ todo: todo } )" >
88 <label v-text =" todo.text" @dblclick =" editing = true" ></label >
9- <button class =" destroy" @click =" deleteTodo(todo)" ></button >
9+ <button class =" destroy" @click =" deleteTodo({ todo: todo } )" ></button >
1010 </div >
1111 <input class =" edit"
1212 v-show =" editing"
1919</template >
2020
2121<script >
22+ import { mapActions } from ' vuex'
23+
2224export default {
25+ name: ' Todo' ,
2326 props: [' todo' ],
2427 data () {
2528 return {
@@ -36,15 +39,23 @@ export default {
3639 }
3740 },
3841 methods: {
39- toggleTodo (todo ) {
40- this .$store .call (' toggleTodo' , todo)
41- },
42+ ... mapActions ([
43+ ' editTodo' ,
44+ ' toggleTodo' ,
45+ ' deleteTodo'
46+ ]),
4247 doneEdit (e ) {
4348 const value = e .target .value .trim ()
49+ const { todo } = this
4450 if (! value) {
45- this .$store .call (' deleteTodo' , this .todo )
51+ this .deleteTodo ({
52+ todo
53+ })
4654 } else if (this .editing ) {
47- this .$store .call (' editTodo' , this .todo , value)
55+ this .editTodo ({
56+ todo,
57+ value
58+ })
4859 this .editing = false
4960 }
5061 },
Original file line number Diff line number Diff line change 1+ import 'babel-polyfill'
12import Vue from 'vue'
23import store from './vuex/store'
34import App from './components/App.vue'
Original file line number Diff line number Diff line change @@ -6,5 +6,5 @@ export const toggleAll = makeAction('TOGGLE_ALL')
66export const clearCompleted = makeAction ( 'CLEAR_COMPLETED' )
77
88function makeAction ( type ) {
9- return ( { dispatch } , ... args ) => dispatch ( type , ... args )
9+ return ( { dispatch } , payload ) => dispatch ( type , payload )
1010}
Original file line number Diff line number Diff line change @@ -17,26 +17,26 @@ const state = {
1717}
1818
1919const mutations = {
20- ADD_TODO ( state , text ) {
20+ ADD_TODO ( state , { text } ) {
2121 state . todos . push ( {
22- text : text ,
22+ text,
2323 done : false
2424 } )
2525 } ,
2626
27- DELETE_TODO ( state , todo ) {
27+ DELETE_TODO ( state , { todo } ) {
2828 state . todos . splice ( state . todos . indexOf ( todo ) , 1 )
2929 } ,
3030
31- TOGGLE_TODO ( state , todo ) {
31+ TOGGLE_TODO ( state , { todo } ) {
3232 todo . done = ! todo . done
3333 } ,
3434
35- EDIT_TODO ( state , todo , text ) {
36- todo . text = text
35+ EDIT_TODO ( state , { todo, value } ) {
36+ todo . text = value
3737 } ,
3838
39- TOGGLE_ALL ( state , done ) {
39+ TOGGLE_ALL ( state , { done } ) {
4040 state . todos . forEach ( ( todo ) => {
4141 todo . done = done
4242 } )
You can’t perform that action at this time.
0 commit comments