I am developing a single-page application using Vuex and Vue-router.
I currently have a store consisting of a large object - say X - loaded from a database with an identifier. I use the Vue-router to navigate between the pages of the SPA.
Once in a while the user may wish to load another version of X from the database. When doing this, I also want to navigate the user to the "start page". Both the "start page" and the page the user is currently on will display a lot of information taken from the store via computed properties.
As I see there are two ways I can handle this, but none of them are good:
- I load the new object into the store and then push the router.
- Issue: When I have loaded the object into the store from the backend all the reactiveness starts to happen and the current page the user is on will read the new information and act weird.
- I push the router first and then update.
- Issue: This is kind of the reverse of the above. The start page will now contain all information of the old version of X and only after a while update to the new version.
For both 1 and 2 I end up with an amount of errors in the front-end/console from e.g. validation of uniqueness.
One solution could be to first navigate the user to a "loading page", then load the new object and then push the router.
To me this seems like a very basic Vue question and I am probably missing some best practice.