When looking at Vuex tutorials, you can see most of them are quite simple.
The logic is explained well, but scalability suffers. How will this wor...
For further actions, you may consider blocking this person and/or reporting abuse
I like this, we need more posts like this in DEV. Thank you for sharing!
Glad to hear that! More content is coming 🙂
Are you sure we don't need more Dark Mode posts instead?? 😂
But in all seriousness, this is exactly what DEV needs. Solid post @domagojvidovic 👏
Ahh dark mode, more like "dark more!"
Built a large application with 4 modules, after 2 years of working on it I an say in full confidence that if you need modules you might as well just build a seperate application.
In no way did it create any advantages to have it all as one application. Even for shared components ad we eventually moved to a shared design system.
But building a new application sometimes isn't an option...
How does
mapActions
know about the namespacing? Wouldn't identically named actions/mutations still cause problems when called from a component?Easy
Awesome - I use
createNamespacedHelpers
but I guess I never realized that worked the same way as usingmapActions
directly with a namespace as the first parameter!I like having strong types for my actions/mutations without having to import something, so I create an
action
function that uses JS Doc type unionsIn my SFCs I can use it like this:
The value I can pass to
dataAction
is strongly typed to be only one of the keys ofactionTypes
.Never used Vuex Modules before but NuxtJS provides a way through subdirectories I believe, I wonder if it uses this under the hood
This is exactly what Nuxt is doing under the hood.
Hmm, I'm not sure that it's connected
I tried to make it in a small tutorial project on my own.
I got an error: "[nuxt] store/index.js should export a method that returns a Vuex instance. "
Maybe I'm a bit to stupid for it, but in /store/index.js is a function called "export default new Vuex.Store({...})
That's the exported method to return a Vuex instance...
That's so difficult for now :-(
This is fantastic. Thanks :)
I didn't know about this and have been putting everything in one file. I'll definitely be using this technique in the future.
Glad you like it! Start as soon as possible :) let's tackle that tech debt!
Love this. It would have helped me greatly when we were setting up our apps.
Thanks a lot mate! We need more tutorials/guides about scaling a huge system, not just the basics!
The first Vue Apps I built at work I didn't know about modules and the stores definitely got a bit out of hand 😅
I can imagine that chaos 😆
I'm still learning js and vue. I love posts like this to learn best practice from the beginning.
Yep, it's good to create as low tech debt as possible!