PureMVC Architects Lounge

Announcements and General Discussion => Architecture => Topic started by: tucdough on February 21, 2010, 08:18:53



Title: Proxy and nested data
Post by: tucdough on February 21, 2010, 08:18:53
Hi,

i think PureMVC works great with apps that are using "flat" data (e.g. one object with members of primitive data types) but not with complex and hierarchical data (objects having lists of other objects)?

Every proxy and mediator needs to get named. This won't let me create more than one instance otherwise naming gets messy?

I would like to know how a proxy might look like to work with nested data.



Title: Re: Proxy and nested data
Post by: puremvc on February 22, 2010, 10:13:45
Proxies and Mediators can be dynamically named allowing you to have more than one instance. As long as the name you pass to the super class constructor is unique, you're set. The idiom of using a NAME constant is for the 90+% of Mediators and Proxies that only ever need a single instance.

As far as nested data goes, the data object of a Proxy can be a complex object or a collection of such. If the Proxy needs to expose methods to work with parts of the data, it can do so, but can become a little chunky if it has lots of methods. At which point I often create other proxies for the sub-objects and have the proxy for the master object register the sub object proxies with its reference to them. This is the same as how a Mediator for a complex object may register other mediators for its view component's children.

-=Cliff>