[Vuejs]-VueJS define computed logic in two components vs. in $store

0👍

Realistically there will be little performance difference either way. In terms of your code duplication vs $store abstraction problem – personally I find that a small amount of duplication lends to better readability and maintainability. When compared to pushing that function to somewhere else.

This article explains why that can be the case much better than I could.

You need to consider whether it makes sense for a $store to have a function for normalising a name. Also if more than just these two component use the store – that function probably belongs in the components themselves rather than in the store. To me that normalisation functionality would look out of place in a store.

Perhaps if you thought that function was going to be needed to be implemented a 3rd time, then you should find a way to move it elsewhere for the sake of consistency/convenience.

Leave a comment