PureMVC Architects Lounge

PureMVC Manifold => MultiCore Version => Topic started by: caiomeriguetti on July 21, 2010, 02:02:56



Title: Mediators can have multiple viewcomponents?
Post by: caiomeriguetti on July 21, 2010, 02:02:56

is that possible?


Title: Re: Mediators can have multiple viewcomponents?
Post by: Tekool on July 21, 2010, 02:52:15
The definition of the mediator pattern (http://en.wikipedia.org/wiki/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.



Title: Re: Mediators can have multiple viewcomponents?
Post by: caiomeriguetti 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


Title: Re: Mediators can have multiple viewcomponents?
Post by: Tekool 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.