Reputation: 2456
I am trying to understand the principle of communication between components and a doubt has arisen: what is the main difference between Vue event bus strategy and Vuex to deal with components communication? Besides that, when is the best time of use of each one and what is the best practice to use both in the same project?
Upvotes: 13
Views: 6597
Reputation: 35684
the vue event bus is a separate instance of Vue. Vuex is a (flux based) state managment library that integrates with the current instance of Vue, and adds a lot of functionality.
I think you shouldn't be using the event bus at all if you can solve an issue using Vuex.
Vuex implements the flux pattern that allows components to easily subscribe to changes based on store mutations.
img src: https://medium.com/@cabot_solutions/flux-the-react-js-application-architecture-a-comprehensive-study-fd2585d06483
Upvotes: 16