Vuex: Getter with payload

Created on 16 Jul 2018  路  5Comments  路  Source: vuejs/vuex

What problem does this feature solve?

I think there are already many issues for this, I just want to say this feature is very very very important, I know that perhaps we can use a mutation to do the same work just with a return. But mutation is for change the state, if I use it like this, I will be doing something too strange that I don't want really want to do.

I hope really Vuex getters can have a payload.

Last question, I think there maybe also a design problem with the name getter. In fact, if a getter return directlly the state, then we can change the state use this getter. It's strange because it's just a getter not getter&&setter.

I hope really someone can fix the two problems, for a long time I think I can work with these problems exist.....it's not true now......

What does the proposed API look like?

  1. getter can have a payload
  2. getter cant change directly the state
duplicate

Most helpful comment

As @lloydjatkinson described.

All 5 comments

526 covers this; you can already pass a payload to a getter. This is covered by https://vuex.vuejs.org/guide/getters.html#method-style-access

As @lloydjatkinson described.

We can only use other getters for now, but sometimes I need to pass a value to a component and the component use it鈥檚 state and this value to calculate. Finally it return the result

Did you read the example shown in the link?

Sorry, I didn't see that carefully. Thanks for the support which is important for me!

Was this page helpful?
0 / 5 - 0 ratings