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: Proxy to view problem  (Read 9319 times)
Ventis
Newbie
*
Posts: 3


View Profile Email
« on: August 24, 2008, 12:22:55 »

Hi everyone,

I've only recently started developing real-life projects based on the pureMVC framework and frankly, it's been hard but fun to learn.

I get the whole concept of using binding or notifications to get variables or object from proxy back to the views but the other day I found myself wanting to trigger a function a view from a proxy. In fact, the function is in a sub-component of the actual view. I need this functionality because I want to trigger the function when I get a result from the proxy. Does anyone know (the best) way to call a function in a sub-component of a view from a proxy?

Thx in advance.
Logged
danielcsgomes
Full Member
***
Posts: 47

 - daniel@onedesign.com.pt
View Profile Email
« Reply #1 on: August 24, 2008, 12:26:27 »

Hi Ventis,

Why don't you send a notification from proxy that the sub-component mediator will hear and call the function?
It looks to me the best way and practice to do that.


Daniel Gomes
Logged
Ventis
Newbie
*
Posts: 3


View Profile Email
« Reply #2 on: August 25, 2008, 12:26:53 »

I see, I thought, keeping the framework in mind, you should only catch notifications in mediators?

So how would I catch the notification in the subcomponent, because it doesn't have the handleNotification method?
Logged
danielcsgomes
Full Member
***
Posts: 47

 - daniel@onedesign.com.pt
View Profile Email
« Reply #3 on: August 25, 2008, 12:35:26 »

Yes, only in mediators you can handle the notification, look at this example:

SubComponentMediator.as
:
protected function get subComponent():SubComponent
{
return viewComponent as SubComponent;
}
override public function listNotificationInterests():Array
{
    return [ApplicationFacade.RESULT_FROM_PROXY_SUCCESS]
}

override public function handleNotification( note:INotification ):void
{
switch ( note.getName() )
{
case ApplicationFacade.RESULT_FROM_PROXY_SUCCESS:
//let's call the subcomponent function
subComponent.myFunction();
break;
}
}

and in your proxy just need this:

ExampleProxy.as
:
private function getResult(event: ResultEvent):void
{
CursorManager.removeBusyCursor();

// notify all interested members
sendNotification(ApplicationFacade.RESULT_FROM_PROXY_SUCCESS);
}

You can call function of your components inside of his mediator, the component was his mediator to handle the notification from proxy to tell him what to do.

Hope it helps,

Daniel Gomes
Logged
Ventis
Newbie
*
Posts: 3


View Profile Email
« Reply #4 on: August 25, 2008, 01:26:41 »

Thx Daniel, you solved my problem.  :)
Logged
Pages: [1]
Print