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  Announcements and General Discussion / General Discussion / RemoteObject as Singleton instance on: March 03, 2010, 02:12:39
I have several proxys in my application that invoke to some remote objects. Different proxys can call to same operations in remote objects. I have defined a singleton wrapper service object which holds an instance of RemoteObject. The service exposes a getOperation() method that returns remote object operations. Proxys obtain references to the singleton service to obtain remote object operations. I've noticed that Flex RemoteObject.getOperation() method returns always the same operation object reference from RemoteObject, so new result and fault event listeners are added to existing ones. Then problem is multiple event listeners for same operation are been fired when operation is invoked, resulting in different proxy event listeners been executed. I only need one event listener to be fired (the one who is related to operation invoked in the proxy).

My remote service looks like:

:
private class RemoteService
{
                protected static var _remoteService:Service = new RemoteService();
               
protected var _destination:String;

protected var _remoteObject:RemoteObject;

public function RemoteService(destination:String)
{
this._destination = destination;
this._remoteObject = new RemoteObject();
this._remoteObject.destination = destination;
}
           
                public static function getInstance():RemoteService
                {
                        return _remoteService;
                }

public function getOperation(operationName:String, onResult:Function, onError:Function) : Operation {
var operation:Operation = _remoteObject.getOperation(operationName) as Operation;
operation.addEventListener(ResultEvent.RESULT, onResult);
operation.addEventListener(FaultEvent.FAULT, onError);
return operation;
}
}

An example of a proxy:

:
public class TestProxy
{
public static const NAME:String = "TestProxy";

                protected var _remoteService:RemoteService;
 
public function TestProxy(){
super(NAME);
                        _remoteService = RemoteService.getInstance();
}

public function testOperation():void
{
var operation:Operation = _remoteService.getOperation("testOperationName", onTestResult, onTestFault);
operation.send();
}

                ...


Many proxys could have a reference to same RemoteService so when invoking testOperationName operation every event listener will be fired in different proxys.

I need a work around of this issue. I've thought of defining RemoteService as a Multiton instead of a Singleton, having one instance for each proxy. The I could have  _remoteService = RemoteService.getInstance(PROXY_NAME) in each proxy. As each RemoteService has a reference to a diffent RemoteObject, operations will be unique too for each Proxy.
But then I will have many RemoteObject references (one for each proxy), with consecuent memory consumption (now I have only one RemoteObject reference).

Is this approach acceptable?

Thank you very much.
2  PureMVC Manifold / MultiCore Version / PureMVC module unloading on: January 27, 2010, 08:48:48
Hi!
I'm developing a Flex applications based on PureMVC MultiCore and Fabrication.
I'm handling module unloading with following code when needed:

:
ModuleManager.getModule(MODULE_URL).unload();
I would like to free PureMVC module classes acquired memory (including mediators, proxys, etc.) and also MXML classes.

I've noticed that MXML creation complete event is been fired only once, when it is first viewed. I think if module is unloaded properly MXML views should be recreated. Am I right?

Is any extra procedure needed to unload PureMVC related classes when unloading modules?

Thank you in advance.

Daniel.
3  Announcements and General Discussion / Fabrication / Routed notification received many times on: November 20, 2009, 06:46:27
Hi!

I have routed a notification from a module to another one and the module that receives the notification is receving it four times instead of one as expected.
I don't know if I'm doing something wrong.

The code is:

In mediator code of the Module that sends the notification:

routeNotification(UserAdminModule.NTF_SHOW_USERS_LIST, null, null, "*");

In mediator code of the Module that receives the notification:

override public function listNotificationInterests():Array
{
 return [UserAdminModule.NTF_SHOW_USERS_LIST];
   
}

override public function handleNotification(notification:INotification):void {

 switch(notification.getName()) {
  case UserAdminModule.NTF_SHOW_USERS_LIST:
   userAdmin.setNavigationView(UserAdmin.VS_INDEX_USERS_LIST);
   mediatorsForUsersList();
   break;
 
  default:
   trace("[WARN]: Notification not handled: " + notification.getName());
 }
   
}

Can anyone help me?
Thanks
4  Announcements and General Discussion / General Discussion / Multiple proxys orchestration from Command 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.
5  PureMVC Manifold / MultiCore Version / Module PureMVC deferred initalization issue on: September 24, 2009, 02:33:23
Hi!
I'm developing a Flex3 multicore PureMVC application and I'm having the following issue.
From the Shell I have to show a module with a certain view. The active view is set throught a method published in the module interface. Before invoking the method, I have to wait till Module is ready with ModuleEvent.READY event. When this occurrs, I invoke the method on the module but the READY event fires before the Module creationComplete is fired that is where I initialize PureMVC in the module. So I can't access PureMVC to set init view in the module.

Could anyone tell me If I'm doing anything wrong or suggest me a solution to this problem?

Thanks in advance,

Daniel.
6  Announcements and General Discussion / General Discussion / Do I need to use MultiCore PureMVC version? on: December 19, 2008, 05:28:18
Hi!
I'm working on the architecture for a Flex-PureMVC based project which will have different modules. I wonder if it is really necessary to use the MultiCore version of PureMVC to develop Flex applications with modules instead of Standard one. Couldn't communication between modules and main application be effectuated using simple Notifications without pipelines?
I've implemented a test application with one module and a mediator which handles the module. I've inserted a button in the module which sends a notification when it's pressed to the main application mediator. This seems to work.
Which is the main advantage of using MultiCore approach?

Thanks a lot.
Pages: [1]