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: Can i send notifications from mediators to proxies?  (Read 8949 times)
sinosoidal
Jr. Member
**
Posts: 15


View Profile Email
« on: October 15, 2008, 02:30:44 »

Hi,

Before I started doing anything in puremvc i read half of the documentation and try to put the example on the documentation working. I was a little bit disapointed with the example because it was not a complete sample.

In the example, the login command is declaraded on the application facade and then, onTryLogin a notification is sent for that.

However, in the diagram, its possible to comunicate directly between mediators and proxies and thats what i'm trying to do, but its not working.

This is what i'm doing in my mediator:

override public function listNotificationInterests():Array {
            return [AccessProxy.LOGIN,
                  AccessProxy.LOGIN_FAILED,
                  AccessProxy.LOGIN_SUCCESS];
      }
      
      override public function handleNotification(notification:INotification):void
      {
         switch(notification.getName()) {
            case AccessProxy.LOGIN:
               var loginProxy:AccessProxy = facade.retrieveProxy(AccessProxy.NAME) as AccessProxy;
               loginProxy.login(accessPanel.loginVO);
               mx.controls.Alert.show("notification sent");
               break;
         }
      }      
      
      private function onTryLogin(event:Event): void
      {                  
         sendNotification(AccessProxy.LOGIN,accessPanel.loginVO);   
      }

Can anyone clarify me this?

Thanks,

Nuno



Logged
Joel Hooks
Courseware Beta
Sr. Member
***
Posts: 146


baby steps

 - 46288188  - passport@provinsal.com  - joeltuff
View Profile WWW Email
« Reply #1 on: October 15, 2008, 08:45:25 »

No, proxies don't receive notifications. You are communicating directly with your proxy by grabbing its instance and calling methods on it. onTryLogin is sending a Notification which should be retrieved by a Command, which in turn will access the proxy in the same fashion. You could substitute this in the onTryLogin method:

:
               var loginProxy:AccessProxy = facade.retrieveProxy(AccessProxy.NAME) as AccessProxy;
               loginProxy.login(accessPanel.loginVO);

You have a circular reference going here, and AccessProxy.LOGIN is probably not needed at all. Instead you would just have:

:
      override public function handleNotification(notification:INotification):void
      {
         switch(notification.getName()) {
            case AccessProxy.LOGIN_SUCCESS:
               mx.controls.Alert.show("access granted");
               break;
            case AccessProxy.LOGIN_FAILED:
               mx.controls.Alert.show("access denied");
               break;
         }
      } 
 

Logged

http://joelhooks.com - my ramblings about developing with actionscript and python using pureMVC and django respectively.
Pages: [1]
Print