Over 10 years of community discussion and knowledge are maintained here as a read-only archive.
We currently use PureMVC for our flex app. I am comparing PureMVC and Parsley at the moment. Any thoughts?
Also, I am facing an issue where I want to re-use my view and mediator. Should I go about inherting my mediator or creating another intsance of the same mediator by injecting a different name for it? If so, I will have branch my code in every function to check what name it is to make tweaks to code, if any.
Also, as our app is growing I am registering new commands, mediators and proxies, hereby making my startup command really big...any thoughts on this.
and say the following to retrieve it...myMediator = MyMediator(facade.retrieveMediator(MyMediator.NAME));
Now I want to use the existing view and mediator by creating another instance of it, how do I handle this.
public static const NAME:String = "MyViewMediator"; public function MyViewMediator( viewComponent:MyView ) { super( NAME+"/"+viewComponent.id, viewComponent ); }
public static const NAME:String = "MyViewMediator"; public function MyViewMediator( viewComponent:MyView ) { super( getMediatorNameForID( viewComponent.id ), viewComponent ); } public static function getMediatorNameForID( string:id ):String { return NAME+"/"+id; }
var myViewMediator:MyViewMediator;myViewMediator = MyViewMediator( facade.retrieveMediator( MyViewMediator.getMediatorNameForID( id ) ) );
public class MyCollectionProxy extends Proxy{ public static const NAME:String = 'MyCollectionProxy'; public function MyCollectionProxy(proxyName:String) { super(proxyName); } override public function onRegister() : void { //... } public function getMyCollectionByName(id:String):ArrayCollection { var data:ArrayCollection; // ... // ... get data by Name // ... sendNotification(ApplicationFacade.LOAD_DATA_SUCCESS, data, id); } public function getMyCollectionByStatus(id:String):ArrayCollection { var data:ArrayCollection; // ... // ... get data by Status // ... sendNotification(ApplicationFacade.LOAD_DATA_SUCCESS, data, id); } public function loadMyCollectionByStatusService(id:String):void { // ...what should we do with the passed id? // var delegate:MyService = new MyService( new Responder( onLoadDataService, onLoginFaultService ) ); delegate.loadDataByStatus(); CursorManager.setBusyCursor(); } public function onLoadMyCollectionByStatusService(event:ResultEvent):void { CursorManager.removeBusyCursor(); var result:ArrayCollection= event.result as ArrayCollection; setData(result); // // ...where should we get the id // sendNotification(ApplicationFacade.LOAD_DATA_SUCCESS, result, id); }}
public static const NAME:String = "MyViewMediator"; public function MyViewMediator( viewComponent:MyView ) { super( getMediatorNameForID( viewComponent.id ), viewComponent ); } public function getDataByStatus():void { // this will call the registered Command (inside the Command we invoke the proxy remote call) sendNotification(ApplicationFacade.LOAD_DATA_BY_STATUS, false, id); }
public function loadMyCollectionByStatusService(id:String):void { var delegate:MyService = new MyService( new Responder( onLoadDataService, onLoginFaultService ) ); CursorManager.setBusyCursor(); // Set the id on the AsyncToken var token:AsyncToken = delegate.loadDataByStatus(); token.id = id; } public function onLoadMyCollectionByStatusService(event:ResultEvent):void { CursorManager.removeBusyCursor(); var result:ArrayCollection= event.result as ArrayCollection; setData(result); // Get the id from the AsyncToken var token:AsyncToken = event.token; var id:String = token.id; sendNotification(ApplicationFacade.LOAD_DATA_SUCCESS, result, id); }}