Skip to content
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

Not calling vuex Getters when no needed #848

Closed
oscar-gardiazabal opened this issue Dec 12, 2018 · 3 comments
Closed

Not calling vuex Getters when no needed #848

oscar-gardiazabal opened this issue Dec 12, 2018 · 3 comments

Comments

@oscar-gardiazabal
Copy link

oscar-gardiazabal commented Dec 12, 2018

What problem does this feature solve?

A SPA website can have different store modules with specific getters for each screen, which can be associated with ajax requests.
Executing all the getters automatically will not only execute all the associated requests, but also can create inconsistencies or very different behaviour.

What does the proposed API look like?

Maybe getters could be collapsed and disabled by default, and call them all only on expand. Allowing to use the rest of tools normally.

@oscar-gardiazabal oscar-gardiazabal changed the title Calling getters in SPA when no needed Calling getters when no needed Dec 12, 2018
@oscar-gardiazabal oscar-gardiazabal changed the title Calling getters when no needed Not calling vuex Getters when no needed Dec 12, 2018
@Akryum
Copy link
Member

Akryum commented Jan 24, 2019

Are you implying that you are making ajax calls in getters? 🙀

@oscar-gardiazabal
Copy link
Author

oscar-gardiazabal commented Jan 29, 2019

Are you implying that you are making ajax calls in getters?

A handler function requests ajax once

@AlexandreBonaventure
Copy link

So I have this issue with one of my app where evaluating getters on vuex:init is throwing errors and breaks everything. I am using vuex-router-sync and one the getters is written as such :

export const stationId = (state, getters, rootState, rootGetters) => {
  return rootState.route.params.stationId
}

This getter is not meant to be evaluated on init and since vuex-router-sync add the route state module asynchronously it fails.
This is an easy fix :

export const stationId = (state, getters, rootState, rootGetters) => {
  return rootState.route && rootState.route.params.stationId
}

But it feels bad to modify the codebase just for using the devtool.

@Akryum Akryum closed this as completed in 8942bcb Mar 20, 2019
simsim0709 pushed a commit to simsim0709/vue-devtools that referenced this issue May 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants