[Vuejs]-Vuex vs Service for managing state

0👍

I’m relatively new to VueJS, so please take this with a grain of salt.

I think it depends on the size of the app, as well as the complexity. If you’re emitting a lot of events, using state makes sense because you have a single source of truth (a single file, literally) for your app state vs an event bus which will have to be imported into every component. From the Vuex site,

If you’ve never built a large-scale SPA and jump right into Vuex, it may feel verbose and daunting. That’s perfectly normal – if your app is simple, you will most likely be fine without Vuex. A simple global event bus may be all you need. But if you are building a medium-to-large-scale SPA, chances are you have run into situations that make you think about how to better handle state outside of your Vue components, and Vuex will be the natural next step for you. There’s a good quote from Dan Abramov, the author of Redux.

Hope this helps. Good luck 🙂

Leave a comment