-
Notifications
You must be signed in to change notification settings - Fork 57
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
in a computed: const variable = get("propertyName") returns a function instead of the object or the value. #113
Comments
Hey, (I updated your formatting - you might want to follow that format in the future!) Sorry it's a bit confusing first time, but:
If you want to get a value from the store for use in a calculation, use the method on the store. If you want to wire a value from the store as a computed property, use the helper. Is that clear? |
Hey Dave, and here i thought Github was super smart with their formatting :D I'll follow it in the future.
|
FWIW, I find that in code you can treat getters as if they were state, so not much value in naming like methods: // could do this...
const tasks = this.$store.getters.GetTasks; // I think this is clearer
const tasks = this.$store.getters.tasks; Pathify actually has something called "accessor priority" for this situation; if you name the state and the getter the same, it will choose the getter over the state: const tasks = store.get('tasks') // automatically gets the getters https://davestewart.github.io/vuex-pathify/#/api/properties?id=accessor-priority |
Yeah, the docs... they give too much info in parts, and perhaps don't get to the point quick enough in others. I should have gone the API + Guide approach, but ended up doing a kind of "combined" approach which isn't great when you just want to see what the API is! Unfortunately, I have never had the time to go back and redo them. Was thinking about doing them in VuePress... but you know... life! You are welcome to always ask questions here, and I will do my best to answer them 😃 |
In computed i have a function Tasks which return an array.
using VueX:
when i try to do the same using pathify:
However, if i do this:
is there something i am missing here, or is it not supposed to be possible to use Get method within a function?
Updated!
Apparently i needed to do this.$store.get instead. So i am guessing in Computed Properties the
becomes shorthand for
The text was updated successfully, but these errors were encountered: