jiminssy
jiminssy

Reputation: 2431

Understanding what Flux Facebook is trying to solve

Just watched this YouTube video.

Jing here gives an example of the ghost new message count problem and how they fixed it using Flux. What specific series of events would lead to such problem? Is this an issue because of multi-threaded environment? Putting simpler code structuring aside, is flux kind of architecture needed in a single threaded environment like the web browser Javascript?

Upvotes: 2

Views: 1303

Answers (1)

Akshat Gupta
Akshat Gupta

Reputation: 2082

I had a similar doubt as to why one needs flux at all especially in single threaded language. I found this particular question come to my rescue.

The point here is not about being single threaded or multi-threaded. The point here is the binding between model and view being bi-directional using controller. So what raises concern is that model can update the view which in turn can update the model which is depicted in the figure big MVC figure in the video.

Disadvantages

The major disadvantage that is being conveyed in the video is that as the number of independent models and views increase it is very difficult to debug that bi-directional relationship between independent models and views.

The example chat example shown in the video is example of the fact that how as they tried to add different independent views interacting with the chat module how the interaction became more and more complex with each view.

Flux to the Rescue

Flux tries to solve the above problem by just breaking the bi-directional relationship between the model and the view so that each action in the view goes to the dispatcher which updates the model/data-store which when finishing processing updates the view.

As one can notice that as the data-flow is from model to view(unidirectional) and not the other way round the code is much easier to understand and debug and manage.

Upvotes: 4

Related Questions