My team and I are working on the beginnings of medium~large scale application. It's a Vue 2 client rendered application with and asp.net core back-end. The client will be used to manage tens of thousands of items and their status.The application is in its early stages and we've been thinking of ways that we could re-architect our existing client-side store.
Since all of us are new and our self taught we're not really sure what the best pattern is for data management is in a Vue application.
Is there a recommended pattern for data management in a VueJS application?
Our current pattern this:
| |
| +-----------+ |
| | | | +-----------+ +-----------+ +------------+
| | API |---->| | | | | |
| | | | | Router |---->| Vuex |---->| Views/ |
| +-----------+ | | | | |<----| Components |
| ^ | ^ | | | | | | |
| | | | | +-----------+ +-----------+ +------------+
| | | | |Vue |
| | | | +---------------------------|-------------------------
| | | | |
|Client| -----------------------------------
+----|-|---------------------------------------------
| |
+---------|-|------
|Backend | v
| +----------+
| | |
| DB |
| |
| |
+----------+
We have an API controller that contains all our API endpoints. When the application is loaded, in the router's beforeEnter
function we fetch all the data and then commit that to the Vuex store. Then as the user users the application (adding/deleting/editing) items the store is modified and then Vuex calls the API controller and that data is sent to the back-end.
From the research that we've done the opinions on who should call the API and what kinds of data should Vuex store seem mixed. Some blogs and courses say Vuex is the way to manage your API but forum discussions between respectable Vue community members say otherwise. However, the main issue is given Vue's rapid, ever-changing environment articles and discussions from 2018/19 don't really apply to today's Vue.
The current idea that we have is rather than committing from the router to Vuex, we would pass the data from the router to the view and then have the view commit to the store. Views/components would invoke posts instead of Vuex as well. This would limit the responsibility of the store.
We've also looked at the possibility of using Nuxt.js, but their documentation doesn't provide strict guidance on store/API management.