You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Of course, there is no way to use this in such way so we don't have access to props. How can I specify namespace as prop in such case?
The text was updated successfully, but these errors were encountered:
max-frai
changed the title
How to specify namespace for mapGetters through component props
How to specify namespace for mapFields through component props
Feb 22, 2019
I found a dirty workaround. I rewrote method mapFields and calculate getterType in runtime:
...
const field = {
get() {
var getterType = `${this.namespace}/getField`;
return this.$store.getters[getterType](path);
},
set(value) {
var getterType = `${this.namespace}/updateField`;
this.$store.commit(mutationType, { path, value });
}
};
...
Of course, this required namespace to be declared. I understand this is dirt and not for general usage, but maybe it's possible to rewrite mapFields with such functionality?
If it's okay, I can write pull request modifying mapFields with ability to specify inner prop name that we should use in runtime for namespace calculating.
Hey @max-frai! Thank you for your input. If I understand it correctly, this is a duplicate of #24, please use the existing issue for further discussion (if it is no duplicate, please let me know and I'll reopen this issue).
I'll consider accepting a pull request if it can be done in a backwards compatible manner and I'm happy with the resulting API.
I want to pass
namespace
from vuex module withprops
but it seems to be impossible.Of course, there is no way to use
this
in such way so we don't have access to props. How can I specify namespace as prop in such case?The text was updated successfully, but these errors were encountered: