-
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
Poll: Should accessor priority applied to call() like store.set()? #36
Comments
Hmm. On first thought, that seems like a fair optimisation. Can you think of any situation where it would be undesirable? |
Actually, I don't think any undesirable situation technically, but you can leave this case open a few days for other opinions. Also if you wish, I can change the title to a question for others to participate. I may be wrong, but intuitively I thought
Pros: Semantically more correct. We call a mutation or we call an action. Maybe another possibility is to leave
Pros: Method name match between |
Well, You could very easily create a helper to try this out right now if you're eager! function call (path) {
return function (value) {
this.$store.set(path, value)
}
} You'd need to a bit more work if you want to create multiple methods using object and array syntax. |
Yes, I will use that function, because it makes code cleaner. Hope to see it implemented in Also, I'm changing title of the case. |
I vote leave it as is. A method name should convey intent, and I think that call implies an action, therefore it should only call an action. If you switch to it calling an action first, and falling back to a mutation you're causing confusion and also allowing people to potentially run commits in components, which is in itself bad practice. |
Completely agree. It could be better to use
I respect and partly agree with your personal opinion and discipline not to use mutations in components, and in some cases it may be a better practice. However, I don't agree with mutations in components is a bad practice or it should be disallowed. In current situation
This is my opinion, because there is Committing Mutations in Components section in official |
Hi,
store.get()
andstore.set()
prioritise getters over state and actions over mutations, which is great.Is it possible to have same prioritization feature in
call()
?A simplified example:
store/product.js
component
Kind regards,
The text was updated successfully, but these errors were encountered: