0

I am developing a SPA side project using the MVC pattern in vanilla JavaScript. My goal is learning how the MVC pattern can be applied.

It is a simple e-commerce that shows a list of goods to sell. I have different components and each component has a Model a View and a Controller. For instance, one component allows you to select, add, edit and delete a list of products. I have another component (with its own Model, View and Controller) that allows you to do a completely different thing BUT it is displayed a bit differently based on the product that is selected in the previous component.

If every component has its own MVC, how can the state of a component impact another one

Thank you.

blancopado
  • 13
  • 4
  • Sounds like what you really want is to have the same model with different views and possibly different controllers. The idea behind MVC is not to have an M and a V and a C for everything. It's to combine things intelligently. For instance, you might have a single model of a T-shirt product. One View shows a picture that changes based on a selected color; that would have its own controller. Another view might show the same model as an item in a list - it might not have a controller at all, but rather be controlled by the list controller. – Heretic Monkey Jan 27 '22 at 00:12
  • Re the post you just deleted both versions of: A ticket's # exists to identify the ticket. It is a natural key. – philipxy Oct 24 '22 at 22:30

0 Answers0