Title: Proxy and Business Delegate call Post by: thomasvst on October 09, 2007, 05:52:28 Hi there,
if a Proxy has more than one interaction with a business delegate (in charge of asynchronous service call), is there a 'nice' way to handle the response / fault ? I mean that if a Proxy implements 'IResponder' interface, there is only one result / fault function in charge of handling the result. If I want the send a "UserDeleted" notification after a successful "removeUser()" call and a "UserAdded" notification after a successful "addUser()" call, what is the best solution ? Is there a best practice in this case ? Should I implement a Command that implements 'IResponder' in charge of calling the BusinessDelegate and updating the Proxy after a successful call ? Thanks a lot. Title: Re: Proxy and Business Delegate call Post by: puremvc on October 09, 2007, 08:44:23 In PureMVC-land, we try and keep service communication within the realm of the Model, even though a Command could implement IResponder and talk to a service as well.
So you've got a Proxy that is an IResponder to a service that might've been called to do an update, delete, or add. It has only one onFault method and one onResult method. Depending upon what call was made, the onResult method must send a different Notification (i.e. 'userUpdated' or 'userRemoved'). But how do we 'remember' what it was we were doing? The Asynchronous Completion Token (ACT) design pattern is the answer to the problem. With Flex components like HTTPService, when you invoke the service, you get an instance of AsyncToken as the return. This is a dynamic class onto which you can add whatever properties you'd like. For instance, a reminder about what call we just made:
Then later, when the service returns, and the onResult method is passed the event, just check the 'event.token' property, and you'll find it is a reference to the token that you got when you made the call.
-=Cliff> Title: Re: Proxy and Business Delegate call Post by: thomasvst on October 09, 2007, 08:50:34 Thank you.
Title: Re: Proxy and Business Delegate call Post by: immerzeel on November 19, 2007, 07:24:16 Does the token also apply to Remoting calls?
I would like to handle my remoting in a switch function as well. Title: Re: Proxy and Business Delegate call Post by: thomasvst on November 19, 2007, 08:01:40 Yes, it works.
Title: Re: Proxy and Business Delegate call Post by: robcos on April 21, 2008, 06:33:31
Title: Re: Proxy and Business Delegate call Post by: puremvc on April 21, 2008, 06:56:43 Flash is single-threaded.
-=Cliff> |