Closed
Description
Version
3.1.1
Reproduction link
https://codesandbox.io/s/vue-template-4fv3d
Steps to reproduce
- go to link;
- open Console of page in the bottom;
- see the undefined;
What is expected?
In theory,it should show the code of cb.
What is actually happening?
In fact,it's undefined.
According to Vuex
code, wrappedActionHandler
function provide two params.One is payload
,the other is cb
.
// notice the cb
entry.push(function wrappedActionHandler (payload, cb) {
let res = handler.call(store, {
dispatch: local.dispatch,
commit: local.commit,
getters: local.getters,
state: local.state,
rootGetters: store.getters,
rootState: store.state
}, payload, cb) // pass it and do nothing
if (!isPromise(res)) {
res = Promise.resolve(res)
}
if (store._devtoolHook) {
return res.catch(err => {
store._devtoolHook.emit('vuex:error', err)
throw err
})
} else {
return res
}
})
// dispatch function only use payload
dispatch (_type, _payload) {
// check object-style dispatch
const {
type,
payload
} = unifyObjectStyle(_type, _payload)
const action = { type, payload }
const entry = this._actions[type]
// ...
const result = entry.length > 1
? Promise.all(entry.map(handler => handler(payload))) // only payload parameter
: entry[0](payload)
}
So I think cb
parameter is useless and it should be delete from code in order to
eliminate misunderstanding.
Metadata
Metadata
Assignees
Labels
No labels