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: Asynchronous proxy with multiple clients  (Read 7078 times)
gkf
Jr. Member
**
Posts: 10


View Profile Email
« on: November 20, 2009, 12:46:51 »

I have an asynchronous proxy (P1) which uses a remote object to retrieve data from php services (using amfphp).
When my mediator (M1) wants to get data for its view, it calls a function (f1) of P1.
This function calls the php service. Response of php service is caught by another function (f2) of P1.
This function puts the result in a public var of the proxy and sends a notification telling that data has been received.
M1 is an observer of this notification and updates data of its view using P1 public var.

I have a new mediator M2 who needs to use the same service with different parameters.
If I use the same mechanism, P1 will send the notification telling that data has been successfully retrieve and both M1 and M2 will update their data.
I don't want M1 to update its view when M2 uses the service and vice versa.

I have thought of two ways to have the behaviour I expect.

First solution.

When M1 calls f1 function, P1 uses a private var used to store the 'id' of the requester (M1) of the service.
When f2 receives data, it sends a notification depending on the requester (DATA_FOR_M1_RECEIVED, DATA_FOR_M2_RECEIVED).

Second solution.

f1 defines the function listening to the response of the php service depending on the requestor.

I don't like those solutions :(
It would be much better to define function managing response as parameter of the function calling the service.

I'm looking for good ideas ;)

I'm convinced that experienced users of flex have already found elegant solutions for this problem.
Logged
philipSe
Sr. Member
****
Posts: 139


View Profile Email
« Reply #1 on: November 20, 2009, 05:17:46 »

There is a standard idiom with PureMVC, whereby the 3rd arg to sendNotification, the type arg, is used to descriminate between notifications that have the same name.  When handling the notification, the type is checked to see is it relevant.  Maybe that helps.
----Philip
Logged
Pages: [1]
Print