vuejs / vuex

🗃️ Centralized State Management for Vue.js.
https://vuex.vuejs.org
MIT License
28.4k stars 9.56k forks source link

Why vuex2.0 action function only support one argument? #373

Closed leaves4j closed 7 years ago

leaves4j commented 7 years ago
actions: {
  actionB ({ dispatch, commit }, a, b) {

  }
}

The param b is undefined

leaves4j commented 7 years ago

I think actions are the handle of state exposed to user, we shouldn't limit how to user use those functions, I can understand the mutations support one param, it's a payload for state, but it is necessary to limit user to use actions with one param?

lowesyang commented 7 years ago

I agree with you. But i guess Vuex2.0 maybe encourage developers to define new functions in property 'methods' in vm instead of using actions directly to bind to the DOM. In this case, one payload and a couples of arguments are the same.

ktsn commented 7 years ago

Because variadic arguments restrict the extensibility of dispatch and commit. We can add options to their 3rd argument in the future (e.g. commit already has silent option the 3rd argument).

superzw commented 7 years ago

How stupid design,i must do more,more,more stupid things ,when migrate vuex from 1.0 to 2.0. omz!

tamtm commented 4 years ago

How stupid design,i must do more,more,more stupid things ,when migrate vuex from 1.0 to 2.0. omz!

Yes, vue is cool but vuex is so stupid