vendredi 17 avril 2020

When to use vuex root state, getter,actiove etc?

I am using vuex and use namespaced module. But i am little bit confused when i should use root of vuex. For Exam: I have a website in front and a admin panel in back end (after login). In website i have 2 different type (administrator and client) managed by sub domain abc.com and for client A- clienta.abc.com for client B clientb.abc.com When we (administrator ) visit we see a full page layout page (login) without any web page. But when client url is visited like clienta.abc.com , we will see a website that contain 5- 6 web pages in menu bar. Full system is made with vuejs and vuex and vue router. When a user visit a client's website like clienta.abc.com/about , it calls a action api and get data (logo, client name and other header data with footer data, menu data), The api also check if the window.location.host (is administrator or client web) and get data based on subdomain from db. I have a module named home.module.js which has a action that does it. But i am confused whether i should write main logic to get common data in home.module.js (currently has) or in vuex root action? As i need few common data(logo, name etc) in whole site (for administrator or client web) Another reason : when clienta.abc.com is visited home.moudle.js is ok but when abc.com visited then layout page is different then we have to write same logic to mutate home module getters in administrator page. So, i want to know when sould i use vuex main / root state,action etc ? Thanks in advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire