PureMVC Architects Lounge

Announcements and General Discussion => Getting Started => Topic started by: Alterscape on May 27, 2008, 07:20:31



Title: Best Practices for Array of Proxy objects?
Post by: Alterscape on May 27, 2008, 07:20:31
I'm writing a PureMVC AS3 application that (more or less) renders a set of nodes and edges that form a graph. I'm getting the data from a server-side script (Rails 2.0) that generates XML.  Right now I have the application put together enough that my GraphDataProxy successfully downloads and parses the xml file containing the list of nodes and edges. Each node and edge element also contains an ID that, when appended to a known URL, will retrieve another XML file with details for that node or edge. 

So what I'd really like to do is traverse the nodes in the graph XML document and for each node elementcreate a NodeDataProxy (which loads the details from the node ID), NodeMediator and NodeView that are communicating with eachother. However, I don't see a clean way of giving each NodeDataProxy  and its' notifications unique IDs, so that one NodeDataProxy doesn't trigger events on every NodeMediator.    I'm also not entirely sure where I should be adding the new NodeDataProxies as they're created, or how I should be accessing them..

I think I'm thinking about this problem in the wrong way, given the PureMVC toolset.  Anyone have any thoughts on what the "right" way might be?  on NodesDataProxy containing an array of NodeValueObjects?  But that still doesn't solve the notification issue..


Title: Re: Best Practices for Array of Proxy objects?
Post by: puremvc on May 27, 2008, 10:56:35
You can us e the type property of the Notification to act as a discriminator. Set the unique ID  of the node in the type parameter of the notification and the in the mediator, check the notification.getType() to see if that particular mediator needs to act.

-=Cliff>


Title: Re: Best Practices for Array of Proxy objects?
Post by: PhoneTech on June 23, 2008, 05:18:53
I am working in the same way as the TS. I traverse down the nodes, and instantiate new proxies for each node.

I rather only have one proxy object, but were afraid to use the type descriminator, because that would "break" the puremvc model.

But, if this is confirmed by mister puremvc himself, I think I will go back to a single proxy for all tree objects


Title: Re: Best Practices for Array of Proxy objects?
Post by: puremvc on June 23, 2008, 11:49:49
One proxy managing multiple objects is usually what you want. Rarely do you need a separate. Proxy for each data object in a collection.

-=Cliff>