Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Mediator or Command?  (Read 5696 times)
Alci
Newbie
*
Posts: 5


View Profile Email
« on: January 20, 2010, 03:31:28 »

I am new to PureMVC, and the current site I am building is the first one will be built with PureMVC. It's with several sections, and each section has some elements, some of them are similar, like all sections will have main menu, but the menu on the home page will be different from the inside pages, and there are two sections have product detail box, but one of them are verticle, another is horizontal.

My questions:
1. Should I use mediator or command for sections? I thought I can build mediator for each elements, like menu or product detail box, then use command to load them together into the stageMedaitor. But it's also possible to use one mediator for each section. Which method should I choose?

2. If I use mediator for different sections, should I build one for each, or should I use one mediator for all sections? For example, should i build HomePageMediator/ProductPageMediator/ContactUsMediator or should i just build sectionMediator then writing code inside to load other different mediators?


Thanks a lot for the help from you guys.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: January 20, 2010, 10:24:32 »

The ratio of Mediators to view components depends on how much mediation is taking place. Some people make one big ApplicationMediator and let every event that needs to be heard bubble up through the view hierarchy and be handled in this one Mediator. I don't advocate that but likewise, I don't advocate a one-to-one relationship either.

Usually the way to start is with one Mediator at the app level, then as you fill out the hierarchy. Then that Mediator in its onRegister will instantiate and register Mediators for the major sub components that need mediation. And similarly those Mediators may in turn register Mediators for the major sub components of their view components.

-=Cliff>

Logged
Pages: [1]
Print