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 / Architecture / Mediators and View Components: Am I doing this right? on: September 15, 2010, 10:48:56
What I'm doing NOW:

Often multiple instances of the view component would be used in multiple places in an application.  Each time I do this, I register the same mediator with a different name. 

When a notification is dispatched, I attach the name of the mediator to the body of the notification, like so:

:
var obj:Object = new Object();
obj.mediatorName = this.getMediatorName();
obj.someParameter = someParameter;

sendNotification ("someNotification", obj);

Then in the Command class, I parse the notification body and store the mediatorName in the proxy. 

:
var mediatorName:String = notification.getBody().mediatorName;
var params:String = notification.getBody().someParameter;

getProxy().someMethod(params, mediatorName);

On the return notification, the mediatorName is returned with it.

:
var obj:Object = new Object();
obj.mediatorName = mediatorName;
obj.someReturnedValue= someReturnedValue;

sendNotification ("someReturnedNotification", obj);

In the multiple mediators that might be watching for "someReturnedNotification," in the handleNotification(), it does an if statement, to see
:
if obj.mediatorName == this.getMediatorName returns true.  If so, process the info, if not, don't.

My Question is:
Is this the right way of using Multiton PureMVC?  My gut feeling is not.  I am sure there's a better way of architecting the application so that I don't have to test for the mediator's name to see if the component should be updated with the returned info.

Would someone please help and give me some direction as to what is a better way?

Thanks.
2  Announcements and General Discussion / Getting Started / Mediators to Mediators on: April 07, 2010, 02:24:09
Hi,

I'm just starting to use pureMVC and I have a couple of questions... (I don't want to break any pureMVC BP and rules):

1. I was wondering -- is it okay to use notifications to talk from mediators to mediators?  Or do I have to have mediator #1 to talk to a command, which dispatches another notification that mediator #2 will be interested in?

2. Parent mediators *can* have access to children mediators... question is, is this a BAD thing to do?  Like, if in a mediator, I'm registering another mediator... and then in that parent mediator, I want to access a function in that child mediator... is that breaking any BP or rules?


Thanks. :)
Pages: [1]