Skip to content

Commit 5b6adc0

Browse files
committed
rename: dispatch -> commit, trigger -> dispatch
1 parent 28df9a0 commit 5b6adc0

File tree

12 files changed

+60
-63
lines changed

12 files changed

+60
-63
lines changed

examples/chat/components/MessageSection.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default {
4242
sendMessage (e) {
4343
const text = e.target.value
4444
if (text.trim()) {
45-
this.$store.trigger('sendMessage', {
45+
this.$store.dispatch('sendMessage', {
4646
text,
4747
thread: this.thread
4848
})

examples/chat/components/ThreadSection.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default {
4040
},
4141
methods: {
4242
switchThread (id) {
43-
this.$store.trigger('switchThread', { id })
43+
this.$store.dispatch('switchThread', { id })
4444
}
4545
}
4646
}

examples/chat/vuex/actions.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import * as api from '../api'
22
import * as types from './mutation-types'
33

4-
export const getAllMessages = ({ dispatch }) => {
4+
export const getAllMessages = ({ commit }) => {
55
api.getAllMessages(messages => {
6-
dispatch(types.RECEIVE_ALL, {
6+
commit(types.RECEIVE_ALL, {
77
messages
88
})
99
})
1010
}
1111

12-
export const sendMessage = ({ dispatch }, payload) => {
12+
export const sendMessage = ({ commit }, payload) => {
1313
api.createMessage(payload, message => {
14-
dispatch(types.RECEIVE_MESSAGE, {
14+
commit(types.RECEIVE_MESSAGE, {
1515
message
1616
})
1717
})
1818
}
1919

20-
export const switchThread = ({ dispatch }, payload) => {
21-
dispatch(types.SWITCH_THREAD, payload)
20+
export const switchThread = ({ commit }, payload) => {
21+
commit(types.SWITCH_THREAD, payload)
2222
}

examples/counter-hot/vuex/actions.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
export const increment = ({ dispatch }) => dispatch('increment')
2-
export const decrement = ({ dispatch }) => dispatch('decrement')
1+
export const increment = ({ commit }) => commit('increment')
2+
export const decrement = ({ commit }) => commit('decrement')
33

4-
export const incrementIfOdd = ({ dispatch, state }) => {
4+
export const incrementIfOdd = ({ commit, state }) => {
55
if ((state.count + 1) % 2 === 0) {
6-
dispatch('increment')
6+
commit('increment')
77
}
88
}
99

10-
export const incrementAsync = ({ dispatch }) => {
10+
export const incrementAsync = ({ commit }) => {
1111
setTimeout(() => {
12-
dispatch('decrement')
12+
commit('decrement')
1313
}, 1000)
1414
}

examples/counter/store.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ const mutations = {
2626
// actions are functions that causes side effects and can involve
2727
// asynchronous operations.
2828
const actions = {
29-
increment: ({ dispatch }) => dispatch('increment'),
30-
decrement: ({ dispatch }) => dispatch('decrement'),
31-
incrementIfOdd ({ dispatch, state }) {
29+
increment: ({ commit }) => commit('increment'),
30+
decrement: ({ commit }) => commit('decrement'),
31+
incrementIfOdd ({ commit, state }) {
3232
if ((state.count + 1) % 2 === 0) {
33-
dispatch('increment')
33+
commit('increment')
3434
}
3535
},
36-
incrementAsync ({ dispatch }) {
36+
incrementAsync ({ commit }) {
3737
return new Promise((resolve, reject) => {
3838
setTimeout(() => {
39-
dispatch('increment')
39+
commit('increment')
4040
resolve()
4141
}, 1000)
4242
})

examples/shopping-cart/components/Cart.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default {
3030
},
3131
methods: {
3232
checkout (products) {
33-
this.$store.trigger('checkout', products)
33+
this.$store.dispatch('checkout', products)
3434
}
3535
}
3636
}

examples/shopping-cart/components/ProductList.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default {
2323
'addToCart'
2424
]),
2525
created () {
26-
this.$store.trigger('getAllProducts')
26+
this.$store.dispatch('getAllProducts')
2727
}
2828
}
2929
</script>
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
import shop from '../api/shop'
22
import * as types from './mutation-types'
33

4-
export const addToCart = ({ dispatch }, product) => {
4+
export const addToCart = ({ commit }, product) => {
55
if (product.inventory > 0) {
6-
dispatch(types.ADD_TO_CART, {
6+
commit(types.ADD_TO_CART, {
77
id: product.id
88
})
99
}
1010
}
1111

12-
export const checkout = ({ dispatch, state }, products) => {
12+
export const checkout = ({ commit, state }, products) => {
1313
const savedCartItems = [...state.cart.added]
14-
dispatch(types.CHECKOUT_REQUEST)
14+
commit(types.CHECKOUT_REQUEST)
1515
shop.buyProducts(
1616
products,
17-
() => dispatch(types.CHECKOUT_SUCCESS),
18-
() => dispatch(types.CHECKOUT_FAILURE, { savedCartItems })
17+
() => commit(types.CHECKOUT_SUCCESS),
18+
() => commit(types.CHECKOUT_FAILURE, { savedCartItems })
1919
)
2020
}
2121

22-
export const getAllProducts = ({ dispatch }) => {
22+
export const getAllProducts = ({ commit }) => {
2323
shop.getProducts(products => {
24-
dispatch(types.RECEIVE_PRODUCTS, { products })
24+
commit(types.RECEIVE_PRODUCTS, { products })
2525
})
2626
}

examples/todomvc/components/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export default {
8181
addTodo (e) {
8282
var text = e.target.value
8383
if (text.trim()) {
84-
this.$store.trigger('addTodo', { text })
84+
this.$store.dispatch('addTodo', { text })
8585
}
8686
e.target.value = ''
8787
},

examples/todomvc/vuex/actions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ export const toggleAll = makeAction('TOGGLE_ALL')
66
export const clearCompleted = makeAction('CLEAR_COMPLETED')
77

88
function makeAction (type) {
9-
return ({ dispatch }, payload) => dispatch(type, payload)
9+
return ({ commit }, payload) => commit(type, payload)
1010
}

0 commit comments

Comments
 (0)