[Vuejs]-How to modularize complex view using vuex

3πŸ‘

βœ…

It’s completely up to you. I would store all domain related data (such as post tags, categories, posts itself) in dedicated module. But if i had another domain (for example products) i woluld create another module (products.js) that would have own tags, categories etc.

Thanks to Vuex namespaced modules it would be clear which tags do you want to access:

// get post tags
this.$store.getters["post/tags"];
{ ...mapGetters("post", ["tags"]) }

// get products tags
this.$store.getter["products/tags"];
{ ...mapGetters("products", ["tags"]) }

Leave a comment