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: Complex (Nested) VOs  (Read 7467 times)
flib
Newbie
*
Posts: 4


View Profile Email
« on: March 05, 2009, 03:16:28 »

I’ve started my first project in puremvc; using fabrication.  Great work guys, really like the framework!
I’m a pure flash / as3 developer and it’s tremendously useful to have such a powerful framework I can use in this environment.

My only very small criticism would be the lack of examples for pure flash.  However once I found the hello world fabrication (http://trac.puremvc.org/Demo_AS3_Flash_HelloFlash) example I was off! 

Anyway I have a question about creating complex VOs.

I have 3 bits of data which my view needs to do its magic. 
  • The first bit of data is gathered from an XML file. 
  • Second bit of data is requested from a remote service which is referenced from within the XML file.
  • The third bit of data are files (mp3s) referenced from the remote service return.

The view needs all this data to be loaded.

It also needs to know how second bit of data relates to the first and how the third bit of data relates to the second.  The order is the key bit of information which is required about the relationships.

So I’m thinking I need 3 different proxys, 1 for each VO.
  • Data1Proxy
  • Data2Proxy
  • Data3Proxy

And 3 different VOs
  • Data1VO.arrayOfData2
  • Data2VO.arrayOfData3
  • Data3VO

The problem with this is that Data2Proxy and Data3Proxy rely on data to be ready (from the previous Proxy) before they can do anything.  I could create commands to chain execute each proxy (or use the startup manager) but in reality I wouldn’t want to ever execute Data2Proxy without first having Data1Proxy do its thing.

Really I want 1 command which I can run to get all this information and notify me when it’s done.

I hope this makes some kind of sense: I don’t feel like I’m on the right track with this. 

Does anyone have any thoughts on what I might do which is better?

Many thanks!
 
Logged
newtriks
Courseware Beta
Full Member
***
Posts: 23


 - newtriks
View Profile WWW Email
« Reply #1 on: March 05, 2009, 04:02:08 »

Hey,

2 fairly straight forward suggestions would be:

1) onRegister of Data1Proxy send for your XML, when that is successfully received send a notification which runs the RemoteRequestCommand to make Data2Proxy send your remote request.  When you then have your remote results store them in Data2Proxy as typed objects in an ArrayCollection (I presume your mp3 links and data etc).  I am unsure why you need Data3Proxy?

OR

2) Set up a checklist proxy which tracks the progress of your startup?

HTH,

Simon
Logged
flib
Newbie
*
Posts: 4


View Profile Email
« Reply #2 on: March 05, 2009, 04:40:08 »

Hey, thanks for the reply!

At the moment I've got it set up pretty much like how you describe in point 1.  The reason for Data3Proxy is that I want to actually load in the sounds and store those sounds in a proxy - so I can cache them if I need.

I don't think it should make a difference but I should have been clear. The 'process' of loading xml - getting remote data - loading sounds; this happens every time a user makes a selection, not just on app start up.  So the objects will relate to different objects depending on the user selection.

My concern is that each proxy has to know about 2 VOs in order to 'build' the relationship which is required by the view.  Ideally each Proxy would be blind to anything other than than 1 VO.  I can't help but thinking there must be a better way of storing these relationships - perhaps external to the proxies but I don't know what this is.

In effect I'm nesting the Proxies, as they can't work without the previous Proxy. I think they should be independent of one another.

However, maybe I'm thinking too much about it and this is a valid way of doing things.  It's certainly better than if I'd written my usual DoEverything class ;D

Your help is very much appreciated!
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 on: March 05, 2009, 08:13:42 »

Have a look at the StartupManager utility.

-=Cliff>
Logged
Pages: [1]
Print