happypoulp / redux-tutorial

Learn how to use redux step by step
3.76k stars 546 forks source link

"MVC" used in introduction #97

Open Gamadril opened 8 years ago

Gamadril commented 8 years ago

Started with redux by looking at your tutorial. Thanks for sharing. I have a question regarding the introduction:

// To get more clarity how MVC and flux differ, we'll // take a classic use-case in an MVC application: // In a classic MVC application you could easily end up with: // 1) User clicks on button "A" // 2) A click handler on button "A" triggers a change on Model "A" // 3) A change handler on Model "A" triggers a change on Model "B" // 4) A change handler on Model "B" triggers a change on View "B" that re-renders itself

Where is the "C" in "classic MVC" in that chain?

starandtina commented 8 years ago

@Gamadril

In a nutshell, the classic MVC architecture works like this. There is a model that is at the heart of the whole thing. If the model changes, it notifies its observers that a change occurred. The view is the stuff you can see and the view observes the model. When the view is notified that the model has changed, the view changes its appearance. The user can interact with the view (e.g. clicking stuff) but the view doesn’t know what to do. So the view tells the controller(This is the C) what the user did and assumes the controller knows what to do. The controller appropriately changes the model. And around and around it goes.

Gamadril commented 8 years ago

thanks for clarification, but in the text above are only model and views, where is the controller? Is it might be "the click handler" in 2) A click handler on button "A" triggers a change on Model "A"

starandtina commented 8 years ago

@Gamadril Yes, I think you're right. Correct me if I'm wrong.

oliverbenns commented 8 years ago

I agree with @Gamadril .