PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: dancantong on October 29, 2009, 09:37:25

Title: Multiple proxys orchestration from Command
Post by: dancantong on October 29, 2009, 09:37:25
I'm developing a PureMVC Flex application where I need to login a user. I've implemented a command for this where I invoke a proxy method that makes a remote call to a backend operation that checks user credentials. After user is successfully checked, application should retrieve user settings from backend invoking another proxy operation. This operations should be performed one after another and the second only if the first resulted OK (the user was successfully logged). I think the correct way to implemente this is inside the login command that orchestrates the invocatios to both proxy operations (loggin and retrieve settings). But the problem is proxy operations are executed asynchronously and the methods do not return a value to the command, so how could I know from the command if first operation completed succesfully? Is there any way to return a response from proxys to command?

Thanks in advance.


Title: Re: Multiple proxys orchestration from Command
Post by: puremvc on October 29, 2009, 01:51:51
I would suggest investigating the StateMachine and Loadup utilities. Both are capable of doing this, but the approaches are different.

Loadup is a mature and comprehensive utility; focused on this very problem.

StateMachine is focused on controlling transitions between discrete states of your application

Loadup Utility

LoadupAsOrdered Demo

StateMachine Utility

StateMachine Overview:


Title: Re: Multiple proxys orchestration from Command
Post by: dancantong on October 30, 2009, 01:39:07
Thank you Cliff!
As I read the following in PureMVC documentation: "They can be used to perform transactional interactions with the Model that span multiple Proxies, and require Notifications to be sent when the whole transaction completes, or to handle exceptions and take action on failure.", I thought there was an out-of-the-box approach to peform this.
I come from Java MVC frameworks like Struts and Spring where controllers usually interact with multiple data layer operations and then return results to the view layer.