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: General (noob) Question About Proxies and Mediators  (Read 6997 times)
imageaid
Newbie
*
Posts: 2


View Profile Email
« on: January 22, 2009, 10:37:48 »

Hi,

Really starting to get into PureMVC with a large project at the moment and, while I have read the PureMVC PDFs, I am a little unclear on best practices for relationships between views (and mediators) and their data (and proxies). Sorry for the long post.

In my application, a user needs to first be authenticated (no problem here). When authentication is complete, I send a notification "to" the ApplicationFacade, passing the authenticated data as the notification body. The command registered to receive/act upon this notification sends a request to a web service to get some basic (initial) data about the authenticated user.

When the user's data comes back, I apply some basic data to a user VO (first name, etc.). From here, I need to output this on the "screen". Basically, I need to set a value inside a particular view. For the moment, my Command executes two methods on the related proxy. The first method call on my proxy populates the user VO object. The second method call on the proxy is designed to output some of this user's data to the view.

This second method takes the User VO as a parameter and, inside the method, retrieves the view's mediator. Once the mediator is retrieved, I access the view as a property of the mediator and then set the user data to the particular component within the view (just an mx:Label's text property).

Where I'm uncertain about my approach is whether this interaction between proxy, mediator, and view is the correct or "best practice" for setting values in the view component. Am I on the right track? Does such an approach couple classes too tightly?

Any thoughts or direction (a particular tutorial or code snippet on the PureMVC site to review) is most appreciated.

Thank you,
Craig
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: January 23, 2009, 04:37:42 »

A reread of the best practices doc might wortwhile.

The proxy should be calling the service, not the command. And the proxy should not be retrieving the mediator to give it data, it should send a notification that the mediator is interested in.

The model should not know about the view.
-=Cliff>
Logged
imageaid
Newbie
*
Posts: 2


View Profile Email
« Reply #2 on: January 23, 2009, 07:35:38 »

Thanks, Cliff.

I did mistype one item in my note in that I never had the command calling a service. My command class retrieved the proxy and called a method on the proxy which handle the call to the web service.

My concern was with the proxy accessing the mediator; I knew it wasn't right but wasn't sure where to go with it. After another perusal of the PureMVC docs, I better understood the mediator's listening and responding to events, so I moved the mediator manipulation out of the proxy and into the mediator.

Thanks, again,
Craig
Logged
Pages: [1]
Print