Answer the question
In order to leave comments, you need to log in
Is it worth doing the same type methods in vuex?
Hello, maybe the title is not quite correct, I immediately apologize. In general, I’m mastering vuex, learning to work with the server and that mutations that events actually repeat each other, in the sense that there is a bunch of functions they are almost of the same type
. Maybe it’s worth making 1 universal function that will receive the right just the right parameter by type
updateData(state, data, nameData)
and do the same with getters, or would it be bad form to work with the framework?
PS This is my first framework, I don't know much about them at all.
Answer the question
In order to leave comments, you need to log in
So, of course, it is possible, but the meaning of mutations and the view itself is lost. Mutation names tell the developer, both by the name itself and by the mutation logs in Vue DevTools, what happened. And it is very desirable if the mutation is called by some name close to the business. Not "set X value to Y position" (whatever you want to do), but "show header" or "make user logged in".
One function is responsible for one action, no need for generic methods. It will be hard to maintain and over time you will cram more into it, it is universal.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question