Over 10 years of community discussion and knowledge are maintained here as a read-only archive.
Mediator:protected var key:String = "someKeyForThisMediator";protected function onKeyPress(event:Event):void{ proxy.doSomething(key);}override public function handleNotification(notification:INotification):void{ switch (notification.getName()) { case ApplicationFacade.DO_SOMETHING_RESULT: if (notification.getType() == key) updateView(notification.getBody()); break; }}Proxy:protected function doSomething(key=null):void{ service.addEventListener(ResultEvent.RESULT, onDoSomethingResult) var token:AsyncToken = service.send(); token.key = key;}protected function onDoSomethingResult(event:ResultEvent):void{ var key:String = event.token.key; sendNotification(ApplicationFacade.DO_SOMETHING_RESULT, event.result, key);}
Well to me the most clean method is that proxies represent service objects and mediators call directly their methods and wait for notification to retrieve data.With Commands as Responders you can end with dozen commands for one service object. For instance if you have DAO object with insert, update, select, getAll, delete methods you should have for each table all the commands that handle this and in the mediator you would have to send a dozen of notifications and also register all this commands which leads to a total confusion. By using proxies and directly calling its methods you are having one entry point and have a clean way of knowing what to expect to be returned.