What is the difference between Vuex and Event Bus?

早过忘川 提交于 2020-07-08 09:57:11

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/52084679/what-is-the-difference-between-vuex-and-event-bus

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!