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: Mediators can have multiple viewcomponents?  (Read 8009 times)
caiomeriguetti
Newbie
*
Posts: 4

www.labz.com.br

 - meriguettipro@hotmail.com
View Profile WWW Email
« on: July 21, 2010, 02:02:56 »


is that possible?
Logged
Tekool
Sr. Member
****
Posts: 192


View Profile WWW Email
« Reply #1 on: July 21, 2010, 02:52:15 »

The definition of the mediator pattern is "provides a unified interface to a set of interfaces in a subsystem". Regarding this definition, the answer is definitively yes.

By default the Mediator class constructor in PureMVC only has one viewcomponent parameter but you can add as many viewcomponents in parameters as you want in your subclass. You can also manage a list of view component from a Mediator class, in this case your viewcomponent contructor parameter is null.

Logged
caiomeriguetti
Newbie
*
Posts: 4

www.labz.com.br

 - meriguettipro@hotmail.com
View Profile WWW Email
« Reply #2 on: July 21, 2010, 03:08:58 »

Thanks!

just pass as many vc as i want in constructor and compose the mediator with them. Right?

i got confused because there is no place to hold them inside mediator. Something like viewComponentMap.

but you are right. thanks
Logged
Tekool
Sr. Member
****
Posts: 192


View Profile WWW Email
« Reply #3 on: July 22, 2010, 04:47:18 »

>just pass as many vc as i want in constructor and compose the mediator with them. Right?

Right, in the constructor or later by declaring a getter/setter for each, even if it is a good practice not to give those properties the public accessor.

In general you don't need to create a viewComponentMap because you can simply use the display list of the  MovieClip that parentize all the view components or simpler the mediator that "mediate" the parent MovieClip of all the view components you need to manage. So using the parent MovieClip as the viewComponent constructor parameter seems a good idea to me.
Logged
Pages: [1]
Print