Aipi
Aipi

Reputation: 2456

What is the difference between Vuex and Event Bus?

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

Answers (1)

Daniel
Daniel

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.

enter image description here img src: https://medium.com/@cabot_solutions/flux-the-react-js-application-architecture-a-comprehensive-study-fd2585d06483

Upvotes: 16

Related Questions