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
PureMVC Architects Lounge
Announcements and General Discussion
Getting Started
Best Practices for Array of Proxy objects?
Pages: [
1
]
« previous
next »
Author
Topic: Best Practices for Array of Proxy objects? (Read 12404 times)
Alterscape
Newbie
Posts: 1
Best Practices for Array of Proxy objects?
«
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..
Logged
puremvc
Global Moderator
Hero Member
Posts: 2871
Re: Best Practices for Array of Proxy objects?
«
Reply #1 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>
Logged
PhoneTech
Newbie
Posts: 8
Re: Best Practices for Array of Proxy objects?
«
Reply #2 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
Logged
puremvc
Global Moderator
Hero Member
Posts: 2871
Re: Best Practices for Array of Proxy objects?
«
Reply #3 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>
Logged
Pages: [
1
]
« previous
next »
Stack Overflow
GitHub
Linked In
Google Plus
Twitter
Powered by SMF 2.0.15
|
SMF © 2006-2007, Simple Machines LLC
|
Content © 2006-2018, Futurescale, Inc.
Loading...