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

Show Posts

* | |

  Show Posts
Pages: [1]
1  PureMVC Manifold / Standard Version / Re: Remote Objects on: February 26, 2009, 03:10:36
One more question:

Lets say that in MyProxy I have 2 functions that call different methods from Delegate:
 public function callDelegate1():void
   {
      var delegate : Delegate =new Delegate( this );
             delegate.getData1();
        }

 public function callDelegate2():void
   {
      var delegate : Delegate =new Delegate( this );
             delegate.getData2();
        }

  public function result( rpcEvent : Object ) : void
        {
            data = rpcEvent.result;
        }
       
        public function fault( rpcEvent : Object ) : void
        {
            data = new Object();
        }

The Delegate class notifies MyProxy when data is retrieved. The result function is called. If different type of results are expected it's ok, I've resolved that by checking the rpcEvent.result type (one ArrayCollection and the other XML). Now comes the question:
If both functions from delegate class retrieve the same type of data ? How do I handle this ? I thought of something old school like having a property in MyProxy that is set to a specific value when a function is called from Delegate:
private var typeOfResult:String = "";

 public function callDelegate1():void
   {
      var delegate : Delegate =new Delegate( this );
             delegate.getData1();
             typeOfResult = "getData1";
        }

 public function callDelegate2():void
   {
      var delegate : Delegate =new Delegate( this );
             delegate.getData2();
              typeOfResult = "getData2";
        }

  public function result( rpcEvent : Object ) : void
        {
            switch(typeOfResult){
           
            case "getData1": ....
            case "getData2": ....           
}
        }

If there is another approach let me know. thanks
2  PureMVC Manifold / Standard Version / Re: Remote Objects on: February 05, 2009, 12:40:10
Make the proxy implement IResponder and have the Proxy pass itself to the delegate with the call. The delegate should set the Proxy as the responder for the call, not itself. So the response comes directly back to the Proxy not the delegate.

-=Cliff>

public class Delegate{
   
   private var responder:IResponder;
   private ro:RemoteObject;
   
   public function Delegate(responder:IResponder)
   {
      this.responder = responder;
      ro = new RemoteObject("fluorine");
      ro.source = "NameSpace.ClassLibrary";   
   }
   
   public function getData():void
   {
      var token:AsyncToken = ro.DotNetFunction();
      token.addResponder(responder);
   }
}


public class MyProxy extends Proxy implements IProxy,IResponder
{
   ...

   public function callDelegate():void
   {
      var delegate : Delegate =new Delegate( this );
             delegate.getData();
        }
       
        public function result( rpcEvent : Object ) : void
        {
            data = rpcEvent.result;
        }
       
        public function fault( rpcEvent : Object ) : void
        {
            data = new Object();
        }

}


Is it ok like that ? It's similar with CafeTownsend but I am using a remote object with source to .NET to get data, instead of a HttpService from an XML file.
3  PureMVC Manifold / Standard Version / Re: Remote Objects on: February 05, 2009, 01:21:40
The delegate class should return the data to the proxy, which manages access to that data for the rest of the app. Then the proxy sends a notification that the mediator is interested in. It can send the data along in the body of the note or the mediator can retrieve the proxy and get the data when it receives the note.

-=Cliff>

This is what I want to ask you. How do I return data from delegate class to proxy (which is a proxy to proxy communication) so that the proxy to know when to send the notification to the mediator ?
4  PureMVC Manifold / Standard Version / Re: Remote Objects on: February 04, 2009, 08:26:22
Is it ok like this ? :

From view, an event is dispatched to retrieve data, it is caught by a listener defined in mediator, which calls a proxy, which finally will call the Delegate Class in which I have all my remote objects. When data is received from .Net, Delegate Class will send a notification , which is caught by the mediator. Or should I use a Command that, with switch/case depending on the type of the notification, will send a different notification (finally will be caught by a mediator) with the data in body ?
5  PureMVC Manifold / Standard Version / Re: Remote Objects on: February 03, 2009, 06:32:41
Ok. The Delegate Class I used is a Proxy.  How do the proxies, that need the data to send it to mediators, know when the data arrives into the Delegate Class from .Net (because they can't listen to Notifications) ?  Using a Command for each proxy results in a big number of commands. Let me know if I should use another approach. Thanks!
6  PureMVC Manifold / Standard Version / Re: Remote Objects on: February 02, 2009, 04:20:58
ok. so I have a delegate class now, in which I've declared all of my remote objects. I register it at startup, and retrieve it in every mediator I need data. Is it ok to do that or do I have to register proxies that will call my Delegate Class. thanks
7  PureMVC Manifold / Standard Version / Remote Objects on: January 30, 2009, 05:15:38
Is it ok to have all the remote objects declared static in a separate class instead of declaring them into the proxies? I thought of this because I might need at some point to access the same remote object in different proxies. Thanks!
Pages: [1]