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  PureMVC Manifold / MultiCore Version / Re: PureMVC bug? on: December 29, 2011, 02:31:42
thanks Cliff :D LOL
2  PureMVC Manifold / MultiCore Version / PureMVC bug? on: December 27, 2011, 06:04:24
Hello community, i have a strange situation that for me looks like a bug. Here are steps to reproduce:

User interacts with a window behind which i have the following microarchitecture:
myFacade that extends basic Facade
myProxy that extends Proxy behind myFacade.
myproxy has method getData that requests data from server asynchronously (AMF) using AsyncToken and Responder and then passes data to view via sendNotification method.

Now what do i do:
1. I create window, instantiate myFacade and myProxy, and call getData method.
2. Before server responds, user closes the window, so Facade.removeCore is called, and myFacade is removed.
3. Now server responds, and onResult method in myProxy calls sendNotification, which instantiates Facade with my multiton key (it is cached in Notifier) and i get a new Facade instance in the instanceMap of wrong type. LOL

Any ideas? Thanks in advance.
3  Announcements and General Discussion / General Discussion / Re: renaming mediators - why not? on: February 16, 2011, 11:24:10
exactly, Cliff! My case is number 2)
because the document does not have an id before it is saved to database, the document edit mediator name is set using UIDUtil.getUID() - as a temporary mediatorName
the problem is, when the user saves the document, i need to reset mediatorName to the newly received (from database) document id, so hasMediator(<document id>) would return "true"

upon receiving document id, mediator will change its name itself
4  Announcements and General Discussion / General Discussion / renaming mediators - why not? on: February 16, 2011, 12:04:22
lets say i have an application where users can edit documents
every document gets a unique id once it has been saved
the document cannot be opened if already open by the user

i have a facade for document edit module
when a user opens a document, a document edit mediator is created and registered with mediatorName = document id
the problem begins:
1. user clicks "create new document", which does not have an id yet
2. a new document edit window is opened with lets say some UID as temporary mediatorName
3. user saves the document and does not close it
4. user tries to open the same document and succeeds, becuause i check facade.hasMediator(<id of the document>) which returns false

i dont want to double-check / keep my own window map / stuff like that, i'd rather just rename the mediator.
for this purpose ive extended puremvc a bit
here is all i wrote:
:
public class ExtendedFacade extends Facade {
public function ExtendedFacade(multitonKey : String) {
super(multitonKey);
view = ExtendedView.getInstance(multitonKey);
}

override protected function initializeView():void {
if (view != null) return;
view = ExtendedView.getInstance(multitonKey);
}

override protected function initializeController() : void {
if ( controller != null ) return;
controller = ExtendedController.getInstance(multitonKey);
}

public function renameMediator(mediatorName : String, newName : String) : void {
ExtendedView(view).renameMediator(mediatorName, newName);
}
}

public class ExtendedView extends View {
override public function ExtendedView(multitonKey : String) {
super(multitonKey);
}

override protected function initializeView( ) : void {
instanceMap[ multitonKey ] = this;
}

public static function getInstance( key:String ) : IView {
if ( instanceMap[ key ] == null ){
var view : ExtendedView = new ExtendedView( key );
instanceMap[ key ] = view;
}
return ExtendedView(instanceMap[ key ]);
}

public function renameMediator(mediatorName : String, newName : String) : void {
var mediator : IMediator = mediatorMap[mediatorName];
if(!mediator) return;
delete mediatorMap[mediatorName];
mediatorMap[newName] = mediator;
}
}

public class ExtendedMediator extends Mediator {

public function ExtendedMediator(mediatorName : String, viewComponent : Object = null){
super(mediatorName, viewComponent);
}

public function getFacade() : ExtendedFacade {
return facade as ExtendedFacade;
}
}

public class ExtendedController extends Controller {
public function ExtendedController(multitonKey : String) {
super(multitonKey);
}

override protected function initializeController() : void {
view = ExtendedView.getInstance(multitonKey);
}

public static function getInstance( key:String ) : ExtendedController {
if ( instanceMap[ key ] == null ) instanceMap[ key ] = new ExtendedController( key );
return instanceMap[ key ];
}
}

so i have two questions
1. How bad is this solution? Is there a better one?
2. Would it cause any bugs in puremvc that i didnt notice?

thanks in advance!
Pages: [1]