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: Multiple proxies: knowing when they've all returned data  (Read 6602 times)
i_am_cam
Newbie
*
Posts: 4


View Profile Email
« on: November 24, 2009, 04:22:44 »

Hi all, I'm looking for some advice.

I have multiple proxies which make requests for data in their onRegister method. The proxies are all initialised simultaneously in a StartupCommand as the application starts, and the returned data from across all proxies is required before the rest of the application can run (they load navigation, content, etc).

The way I'm planning on handling this was to have a mediator, lets call it ApplicationMediator, which listens for completion notifications from each individual proxy, setting a boolean 'completed' value, and sending an "all data loaded" notification when all the boolean values are true.

Does this sound a reasonable solution, or is there any other alternatives I should be considering?
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: November 24, 2009, 04:37:15 »

If you automatically call services when Proxies are registered then you cannot be assured that the Mediators will be registered and listening for notifications by the time the result is returned to the Proxies and notifications are sent out.

The order of startup is generally that the Model is prepared by registering Proxies. Then the View is prepared by registering Mediators.

In the onRegister of the Mediators, we retrieve the already registered Proxies that we need to collaborate with, and possibly invoke Proxy methods that make the initial service calls.

As for tracking when all the calls are complete (and handling failure/retry and order of operations) you might want to look into the Loadup utility, which handles all sorts of loading scenarios.

Loadup is a pretty comprehensive utility, so if you feel that's too complicated for your needs, you might also have a look at the StateMachine utility which allows you to define a Finite State Machine for your app, and control the progress through the various states.

-=Cliff>
Logged
i_am_cam
Newbie
*
Posts: 4


View Profile Email
« Reply #2 on: November 25, 2009, 03:24:55 »

That makes sense Cliff, thanks for clearing that up.

I think in this instance Loadup may add complications, partially due to my lack of knowledge about it, but I've grabbed the demos from Trac and plan to read through the tutorial soon - might be something I can use next time around.
Logged
Pages: [1]
Print