E
E
eugenedrvnk2020-08-13 11:56:39
Vue.js
eugenedrvnk, 2020-08-13 11:56:39

What is the correct way to use one getter for different vuex modules?

The situation is as follows:
There are two modules - latestNews and selectedNews.
Each of them has the 'news' key in the state, where the data received from the api is written (the structure is identical). Both modules need the same getter to format the data. What is the best way to avoid duplication? Move the getter to another module and then push data into it ( https://github.com/vuejs/vuex/issues/688 )? Or put it in a separate js file, import it into each of the modules and use it as a getter there?

Thank you for your time.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question