First look at the answer of Vuex author Yu Xi

Vuex is actually a Flux specialized for Vue, mainly to match the responsive mechanism of Vue itself. It certainly took some of Redux’s features, such as single-state trees and apis for testing and hot reloading, but selectively dropped some features that didn’t fit in the Vue scenario. Examples include mandatory immutability (which has limited benefits if every state change is tracked), cumbersome apis designed for isomorphism, the need to rely on third-party libraries to obtain local states of the state tree relatively efficiently, and so on (in contrast) So Vue + Vuex is much simpler and doesn’t need to worry about performance. The trade-off is that Vuex can only work with Vue. Vue + Redux is not out of the question, but Redux as a generic implementation certainly doesn’t fit Vue as well as Vuex.

Author: especially the rain stream links: www.zhihu.com/question/38…

Source: Zhihu

Copyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please indicate the source.

Flow of VUex:

Mutations — > Mutations — > State changes — > View changes — > Dispatch — > Actions — >mutations — > State changes — > View changes

Redux flow:

Reducer view — > Actions — > State changes — > View changes

The differences between Vuex and Redux are:

(1) The Action and Reducer functions in Redux are improved, and the mutations change function replaces Reducer, without switch, and the state value only needs to be changed in the corresponding mutation function

(2) Due to Vue’s automatic re-rendering feature, there is no need to subscribe to the re-rendering function, just generate a new State

(3) The sequence of Vuex data flow is as follows :View calls store.mit to submit the corresponding request to the corresponding mutation function in Store -> Store change (VUE automatically renders when it detects the data change)

This article is part of the “Gold Nuggets For Free!” Event, click to view details of the event