What is the best way to store a variable globally if I don't want to have it being observed? #9331
-
Hello, I am quite new to Vue and I was wondering about the best way to store variables globally, if I don't want them being observed. I have a Vue application, where I am using Vuex to store global state. However, one of the "states" is a very large object and I have noticed, that it causes slow loading. I thought, that the loading speed could be improved by not having this particular variable observed, as it is not needed, because it is never modified on this page. I was thinking about couple of options:
Do you have any suggestions, which one of them could be the optimal option? Or would you solve it maybe in a different way? Thank you very much for answers. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
In Vuex, dynamic module registration is available and you should use it, but for new applications, you should consider using Pinia. |
Beta Was this translation helpful? Give feedback.
-
I think you can just export the data as plain JavaScript object in any file, and import it into any vue component as you like. You don't even need a provide/inject pair. |
Beta Was this translation helpful? Give feedback.
In Vuex, dynamic module registration is available and you should use it, but for new applications, you should consider using Pinia.