multiple page components (.vue files) are written by different developers on the team. A set of administrative partition data is used in these pages. This data needs to be obtained by calling the background API with Axios. This data is unchanged for the same user, and multiple page components should use the same data. The access order of these page components is not fixed.
so, my question is, which page is responsible for calling the value of axios and putting it in store? If each page has to be called, it must be unreasonable for the same data to be fetched many times. Does it mean that each page should first determine whether this value exists? if it does not exist, call actions and put it in store, and watch this value change, and then getter this value? Feel that this judgment logic is very troublesome, but also requires all pages to be written in this way, and it takes time to coordinate the code style. Can you encapsulate these judgment logic and call the page directly? How do you use it in practice?
the previous experience of using caching at the backend is to provide a tool class and method for calling. This method encapsulates the code for fetching data, first determines whether it exists in the cache, and returns if it does not exist. If it does not exist, it is put into the cache after it is obtained from the database, and then returned. The caller only needs to call this method, but this is not an asynchronous implementation. I wonder if vuex can be used in this way.