MVC vs. Flux ? Bidirectional vs. Unidirectional? MVC vs. Flux ? Bidirectional vs. Unidirectional? reactjs reactjs

MVC vs. Flux ? Bidirectional vs. Unidirectional?


Real and Pure MVC is unidirectional. It is clear from the the wikipedia diagram pasted in the question.

More than a decade ago, when server side frameworks like Apache Struts implemented a variant of MVC called Model View Presenter (MVP) pattern, they made every request go through controller and every response come back through controller. Everyone continued calling it MVC. Due to inherent nature of the web, any changes in the model cannot be propagated to the view without view sending a request or update. So Pure MVC is not implemented. Rather MVP is implemented.

Few years back, when frameworks like Angular, Ember, Knockout implemented MVC on front end, they implemented another variant of MVC called Model View ViewModel (MVVM) pattern, few folks continued called it MVC. (and few realized that terminology is not important and called it MVW (W stands for Whatever)), none of them implemented pure MVC.

When React was born, they took the opportunity to implement pure MVC (not MVP or MVVM), and renamed it as Flux with few changes. I feel Flux is one more variant of MVC. Although, Flux/React team says it is not MVC, I see lot of parity between both the architectures - Flux and MVC.


Because in Javascript frameworks the MVC does not work the way you depicted. The UI generally communicates bi-directionally with the model, as in:

  1. User types into View input
  2. MVC framework binds onchange() to update a model.
  3. Ajax request brings in new model data.
  4. MVC framework updates View input's value to match model.

In Flux architecture, the UI would only fire an independent action with type and associated data to a dispatcher which would then update the model the same way any background ajax method would update the model.

Reference:http://www.thesoftwaresimpleton.com/blog/2013/03/23/client-side-mvc/

"Client Side MVC is completely different than Server Side MVC"

"We are setting up a two way communication between two objects..."

"In short we are wiring together the value of the firstName property of the Person object to the value property of the input."

http://guides.emberjs.com/v1.10.0/object-model/bindings/

bindings in Ember.js can be used with any object, not just between views and models.


I am an embedded developer and I use MVC pattern in my application. My application is very small and I have set up my architecture to be almost unidirectional MVC. But, I read this article, explaining client side MVC, and some thoughts about differences between MVC and FLUX.

Reference: http://www.christianalfoni.com/articles/2015_08_02_Why-we-are-doing-MVC-and-FLUX-wrong

Traditional MVC

|------|  request   |------------|  request   |-------||      | ---------> |            | ---------> |       || VIEW |  response  |            |  response  |       ||      | <--------- |            | <--------- |       ||------|            |            |            |       |                    | CONTROLLER |            | MODEL ||------|  request   |            |  request   |       ||      | ---------> |            | ---------> |       || VIEW |  response  |            |  response  |       ||      | <--------- |            | <--------- |       ||------|            |------------|            |-------|

FLUX

 COMPONENTS          ACTION CREATORS           STORES    |----------------------<<<<-------------------|    |                                             ||------|            |------------|            |-------||      |  request   |            |  request   |       || VIEW | ---------> |            | ---------> | MODEL |----|      |            |            |            |       |   ||------|            |            |            |-------|   |                    | CONTROLLER |                        ||------|            |            |            |-------|   ||      |  request   |            |  request   |       |   || VIEW | ---------> |            | ---------> | MODEL |   ||      |            |            |            |       |   ||------|            |------------|            |-------|   |   | |                                           |        |   | |--------------------<<<<-------------------|        |   |----------------------<<<<----------------------------|