PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: dbasch on January 14, 2009, 10:11:47



Title: Notification types and commands
Post by: dbasch on January 14, 2009, 10:11:47
Hi all and Cliff,

I often need to have a command execute against specific mediators. Is it incorrect to use notification typing in a command?

:
public class AddAssetCommand extends SimpleCommand implements ICommand {

override public function execute( note:INotification ):void {

var newAssetVO:Asset = note.getBody() as Asset;

var mapInstanceUID:String;

// if we didn't get a map instance Id
// then use all the viewable maps
if (note.getType() != null) {
mapInstanceUID = note.getType();
} else {
var mapProxy:MapProxy = facade.retrieveProxy("MapProxy") as MapProxy;
for each (var mapItem in mapProxy.mapCollection) {
facade.sendNotification(ApplicationFacade.ADD_ASSET_CMD, newAssetVO, mapItem.mapUIComponent.map.name);
}
return;
}


Title: Re: Notification types and commands
Post by: puremvc on January 16, 2009, 06:53:22
mapItem isn't typed here, so I don't know what it is, but there is nothing wrong with using the type field as a discriminator so that only one of the notified Mediators will respond.

-=Cliff>


Title: Re: Notification types and commands
Post by: dbasch on January 16, 2009, 09:52:34
mapItem isn't typed here, so I don't know what it is, but there is nothing wrong with using the type field as a discriminator so that only one of the notified Mediators will respond.

-=Cliff>

Thanks Cliff!

Derek Basch