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 {
42
42
sendMessage (e ) {
43
43
const text = e .target .value
44
44
if (text .trim ()) {
45
- this .$store .call (' sendMessage' , {
45
+ this .$store .trigger (' sendMessage' , {
46
46
text,
47
47
thread: this .thread
48
48
})
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ export default {
40
40
},
41
41
methods: {
42
42
switchThread (id ) {
43
- this .$store .call (' switchThread' , { id })
43
+ this .$store .trigger (' switchThread' , { id })
44
44
}
45
45
}
46
46
}
Original file line number Diff line number Diff line change
1
+ import 'babel-polyfill'
1
2
import Vue from 'vue'
2
3
import Counter from './Counter.vue'
3
4
import store from './store'
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ export default {
30
30
},
31
31
methods: {
32
32
checkout (products ) {
33
- this .$store .call (' checkout' , products)
33
+ this .$store .trigger (' checkout' , products)
34
34
}
35
35
}
36
36
}
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ export default {
23
23
' addToCart'
24
24
]),
25
25
created () {
26
- this .$store .call (' getAllProducts' )
26
+ this .$store .trigger (' getAllProducts' )
27
27
}
28
28
}
29
29
</script >
Original file line number Diff line number Diff line change 16
16
<input class =" toggle-all"
17
17
type =" checkbox"
18
18
:checked =" allChecked"
19
- @change =" toggleAll(!allChecked)" >
19
+ @change =" toggleAll({ done: !allChecked } )" >
20
20
<ul class =" todo-list" >
21
21
<todo v-for =" todo in filteredTodos" :todo =" todo" ></todo >
22
22
</ul >
@@ -81,7 +81,7 @@ export default {
81
81
addTodo (e ) {
82
82
var text = e .target .value
83
83
if (text .trim ()) {
84
- this .$store .call (' addTodo' , text)
84
+ this .$store .trigger (' addTodo' , { text } )
85
85
}
86
86
e .target .value = ' '
87
87
},
Original file line number Diff line number Diff line change 4
4
<input class =" toggle"
5
5
type =" checkbox"
6
6
:checked =" todo.done"
7
- @change =" toggleTodo(todo)" >
7
+ @change =" toggleTodo({ todo: todo } )" >
8
8
<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 >
10
10
</div >
11
11
<input class =" edit"
12
12
v-show =" editing"
19
19
</template >
20
20
21
21
<script >
22
+ import { mapActions } from ' vuex'
23
+
22
24
export default {
25
+ name: ' Todo' ,
23
26
props: [' todo' ],
24
27
data () {
25
28
return {
@@ -36,15 +39,23 @@ export default {
36
39
}
37
40
},
38
41
methods: {
39
- toggleTodo (todo ) {
40
- this .$store .call (' toggleTodo' , todo)
41
- },
42
+ ... mapActions ([
43
+ ' editTodo' ,
44
+ ' toggleTodo' ,
45
+ ' deleteTodo'
46
+ ]),
42
47
doneEdit (e ) {
43
48
const value = e .target .value .trim ()
49
+ const { todo } = this
44
50
if (! value) {
45
- this .$store .call (' deleteTodo' , this .todo )
51
+ this .deleteTodo ({
52
+ todo
53
+ })
46
54
} else if (this .editing ) {
47
- this .$store .call (' editTodo' , this .todo , value)
55
+ this .editTodo ({
56
+ todo,
57
+ value
58
+ })
48
59
this .editing = false
49
60
}
50
61
},
Original file line number Diff line number Diff line change
1
+ import 'babel-polyfill'
1
2
import Vue from 'vue'
2
3
import store from './vuex/store'
3
4
import 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')
6
6
export const clearCompleted = makeAction ( 'CLEAR_COMPLETED' )
7
7
8
8
function makeAction ( type ) {
9
- return ( { dispatch } , ... args ) => dispatch ( type , ... args )
9
+ return ( { dispatch } , payload ) => dispatch ( type , payload )
10
10
}
Original file line number Diff line number Diff line change @@ -17,26 +17,26 @@ const state = {
17
17
}
18
18
19
19
const mutations = {
20
- ADD_TODO ( state , text ) {
20
+ ADD_TODO ( state , { text } ) {
21
21
state . todos . push ( {
22
- text : text ,
22
+ text,
23
23
done : false
24
24
} )
25
25
} ,
26
26
27
- DELETE_TODO ( state , todo ) {
27
+ DELETE_TODO ( state , { todo } ) {
28
28
state . todos . splice ( state . todos . indexOf ( todo ) , 1 )
29
29
} ,
30
30
31
- TOGGLE_TODO ( state , todo ) {
31
+ TOGGLE_TODO ( state , { todo } ) {
32
32
todo . done = ! todo . done
33
33
} ,
34
34
35
- EDIT_TODO ( state , todo , text ) {
36
- todo . text = text
35
+ EDIT_TODO ( state , { todo, value } ) {
36
+ todo . text = value
37
37
} ,
38
38
39
- TOGGLE_ALL ( state , done ) {
39
+ TOGGLE_ALL ( state , { done } ) {
40
40
state . todos . forEach ( ( todo ) => {
41
41
todo . done = done
42
42
} )
You can’t perform that action at this time.
0 commit comments