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: Proxy that does not need to interact with any component at first  (Read 7986 times)
Helmut Granda
Full Member
***
Posts: 47

Flash Developer.


View Profile WWW Email
« on: September 24, 2009, 07:55:28 »

I have a piece of data that needs to be gathered from the browser at the begining of the application. The Data will be used by the application and it is imperative that is available in order for the app to work.
      
Most examples that I have seen are used where Proxys send informations during the life of the app.
      
What I am doing right now is to register the Proxy during the StartupCommand, so do I just register the rest of the actors and have them listen for the event that allows the application to run?
      
I am sure I making this more complicated than it should be.

I have taken the time to look at StateMachine but the more I studied it the more confused I was getting so I am back to square one, where I can understand all the basics properly and then add those new items.
Logged
Helmut Granda
Full Member
***
Posts: 47

Flash Developer.


View Profile WWW Email
« Reply #1 on: September 24, 2009, 08:03:12 »

Another thing that throws me off is in my case. Who initiates the Proxy? Everyone else is waiting for the proxy to be completed but who tells the Proxy to go and fetch the data on the browser?
      
Logged
Helmut Granda
Full Member
***
Posts: 47

Flash Developer.


View Profile WWW Email
« Reply #2 on: September 24, 2009, 08:10:01 »

I just went ahead and used the Proxy itself to start fetching the information and it works but this seems really hacky to me.
            
on the StartupCommand
            
:
facade.registerProxy ( new DataProxy ( ) ) ;            
in the proxy
            
:
public function DataProxy ( ) {
        super ( NAME , new DataVO() ) ;
//hack?
getDataFromBrowser(); // it works but shouldn't i be calling this from somewhere else?
}
            }
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 on: September 24, 2009, 08:26:35 »

Generally you'll prepare the model by registering proxies, then prepare the view by registering mediators. This way we're sure the model is in place before the view tries to use it.

When registered, the mediators will retrieve references to their frequently accessed proxies (good thing we've already registered those, right?) and once those references are in hand, they'll invoke methods on the proxies telling them to go get things.

If every mediator is listening for the same notification from the proxy that the data is ready, then you want to invoke the method on the proxy AFTER all your initial mediators are registered, so this could be the last step of your startup command.

If only one mediator needs that initial response, then it should retrieve the proxy in its onRegister method and then invoke the method on the proxy telling it to get the data.

-=Cliff>
Logged
Helmut Granda
Full Member
***
Posts: 47

Flash Developer.


View Profile WWW Email
« Reply #4 on: September 24, 2009, 08:38:26 »

I think I understand. So in this case the ApplicationMediator and onRegister seem to be the two pieces of the puzzle that were missing.

I wish there was a sample application for every single instance and every single project I am working on so that I could just "copy and paste" and be done with it. kidding kiddding...
Logged
Pages: [1]
Print