I'm building an SPA in Vue.js to manage documents and dashboard for logged users. I face the following problems:
- I have one vuex store with several modules, managing different things.
- One (some) of theses modules are for administration purpose (add new dashboard, edit dashboard... and many things).
- Only very few of the final users will have access to administration area, hence use the admins vuex modules.
It seems not very optimized to have the admin store and states for all the users, so my question is: Is there an architectural way to add modules to the vuex store only on conditions (like, if the user is an Admin)? Maybe some kind of lazy-loading that will load this store only if the user access the admin interface?
EDIT : I will determine who is admin via an async API call, so the solution (if it exists) must allow to change store structure dynamicaly. I'd like to avoid the workaround of creating 2 vue instances. I think this is a common problem that arise in many solutions ? (having a big store for admin purpose that should not be present for common users)