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: Good logic for proxies  (Read 3242 times)
sysaux
Newbie
*
Posts: 4


View Profile Email
« on: April 03, 2009, 06:26:53 »

Hello!

I'm using multicore version of PureMVC and i implemented data modification logic by creating 4 proxies
for data object. For example, to work with "orders" i will write 4 proxy:
 - OrdersFetchProxy
 - OrdersInsertProxy
 - OrdersUpdateProxy
 - OrdersDeleteProxy

because if I implement all of this methods in single proxy class, I don't know
which operation(FETCH, UPDATE or DELETE?) returns OK or FAULT message.

How I may implement all data modification(and another - search, filter etc) operations in a single
proxy class, with different result messages? If proxy executes all income calls one after another,
I may remember current operation type in variable, and return result messages depend on this variable...

P.S.:Sorry for my bad English.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: April 03, 2009, 10:09:08 »

Research the Flex API for the AsyncToken. Essentially when you make a service call you set any properties you want on the token that is immediately given back to you, it is a dynamic object supporting the addition of properties at runtime.

Use the AsyncToken object that is returned when you invoke a service call like this:

:
var token:AsyncToken =myHTTPService.send();
token.currentOperation=OrderProxy.DELETE;
token.orderID = currentOrder;

Later, when the result comes back:

:
var token:AsyncToken =resultEvent.token;

switch(token.currentOperation){

   case OrderProxy.DELETE:
   // delete token.orderID from order collection and send appropriate notification
   break;

   case OrderProxy.ADD:
   // add populated order with db generated id to order collection and send appropriate notification
   break;

   case OrderProxy.UPDATE:
   // replace modified order in order collection and send appropriate notification
   break;


-=Cliff>
Logged
sysaux
Newbie
*
Posts: 4


View Profile Email
« Reply #2 on: April 04, 2009, 03:39:13 »

Thanks, Cliff. You have saved me from writing tonns of unneсessary code!
Logged
Pages: [1]
Print