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 proxys orchestration from Command  (Read 10051 times)
dancantong
Jr. Member
**
Posts: 12


View Profile Email
« on: October 29, 2009, 09:37:25 »

Hi!
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.

Daniel.
« Last Edit: October 29, 2009, 10:08:33 by dancantong » Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 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
http://trac.puremvc.org/Utility_AS3_Loadup

LoadupAsOrdered Demo
http://trac.puremvc.org/Demo_AS3_LoadupAsOrdered

StateMachine Utility
http://trac.puremvc.org/Utility_AS3_StateMachine

StateMachine Overview:
http://puremvc.tv/#P003/

-=Cliff>
Logged
dancantong
Jr. Member
**
Posts: 12


View Profile Email
« Reply #2 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.
Logged
Pages: [1]
Print