views:

30

answers:

0

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.