Please Sell Me on Vuex
I mean this post with the utmost respect for the brilliant minds that brought you Redux. Given that React is a view handler and not a full state controller, it completely makes intuitive sense.
Vuex on the other hand I'm failing to see the use case for, but I feel dirty. I'm coding without it just fine, and everything works great, but I have this nagging sense that I'm doing things wrong, reinforced by the infinite masses of trendy JS articles urging me to join The Church of Framework X.
Can some kind soul out there put into words what makes Vuex awesome and why it was worth it for you to use, given the nature of Vue being so darn good at two-way automagical bind handling?
Thanks for any input.
8 comments
[ 3.0 ms ] story [ 29.6 ms ] threadNot to say that's wrong, just that I'm lacking on concrete rationale. If you get a few minutes, would you be kind enough to link me to further reading on maybe some of the ways Vuex provides a better approach than traditional globals in singleton namespaces? (Or just post here but I don't want to ask you to explain something that's already well documented)
Thanks for your help either way, really appreciate your time.
If you google for it there should be plenty of good resources on this topic. It sounds like maybe you’re relatively new to programming - it only takes running into this situation once to start to understand the reasons for avoiding them.
They’re especially dangerous in JavaScript because of the way it handles scoping. If you accidentally miss a “var” or “let” inside a function you could find yourself mutating global instead of local data.
Vuex lets you scope your data to a module. It also as I described above lets you limit mutations to a known set of operations, which becomes important in a large or long-lived codebase.