New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to re-compute a getter #1474

devindwan opened this Issue Dec 26, 2018 · 1 comment


None yet
2 participants
Copy link

devindwan commented Dec 26, 2018

What problem does this feature solve?

As we all know Vue does not support Map(ES6) right now. However, this Map feature is useful and it can not be replaced by normal object totally. Maybe we can provide an approach to manually re-compute a getter when the depended Map object has been changed. It's not quite elegant and break reactivity rule, but we can temporarily improve such reactivity support by this patch like function before Vue 3.0 is released.

What does the proposed API look like?

const state = {
  map: new Map()

// Some getters depend on the map object. Not a necessary use case, just for example.
const getters = {
  keys: state => {
  values: state => {

const mutations = {
  SOME_MUTATION (state, value) { = value
    // Try to re-compute relevant getters
    recompute(['keys', 'values'])

This comment has been minimized.

Copy link

LinusBorg commented Dec 31, 2018

Getters are just computed properties from Vue, and they should behave like them.

I don't think we want to hack around them in vuex to make this work for your edge case.

You can of course use some hacks to make it work for yourself, like an additional counter state that you increase whenever you mutate the Map, and which you refer to in your getter in a no-op way.

@LinusBorg LinusBorg closed this Dec 31, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment