PureMVC Architects Lounge

PureMVC Manifold => Bug Report => Topic started by: panupan on August 12, 2008, 10:51:05



Title: [FIXED] removeMediator is it a bug?
Post by: panupan on August 12, 2008, 10:51:05
Hello.  I ran across this, is this a bug?



In TestMediator.as I have:

:

private static var counter:int = 1;
private var NAME:String = 'TestMediator' + counter++;
public static const REMOVE_TEST_MEDIATORS:String = 'removetestmediators';

public function TestMediator()
{
super(NAME, null);
}

override public function listNotificationInterests():Array {
return [REMOVE_TEST_MEDIATORS];
}

override public function onRegister():void {
trace(NAME+'.onRegister');
}

override public function onRemove():void {
trace(NAME+'.onRemove ');
}

override public function handleNotification(notification:INotification):void {
trace(NAME+'.handleNotification->'+notification.getName());
switch (notification.getName()) {
case REMOVE_TEST_MEDIATORS:
facade.removeMediator(NAME);
break;
default:
}
}

In BugTest.mxml I have:

:
private var facade:ApplicationFacade = ApplicationFacade.getInstance('bugtest');

private function onCreationComplete(event:Event):void {
facade.registerMediator(new TestMediator());
facade.registerMediator(new TestMediator());
facade.registerMediator(new TestMediator());
facade.registerMediator(new TestMediator());
facade.registerMediator(new TestMediator());
facade.sendNotification(TestMediator.REMOVE_TEST_MEDIATORS);
}


When I run this program, I get this output:

:
TestMediator1.onRegister
TestMediator2.onRegister
TestMediator3.onRegister
TestMediator4.onRegister
TestMediator5.onRegister
TestMediator1.handleNotification->removetestmediators
TestMediator1.onRemove
TestMediator3.handleNotification->removetestmediators
TestMediator3.onRemove
TestMediator5.handleNotification->removetestmediators
TestMediator5.onRemove


What happened to 2 and 4?  Is it wrong to remove mediators in this manner?

Thanks a lot.


Title: Re: removeMediator is it a bug?
Post by: puremvc on August 13, 2008, 08:46:38
This is related to this bug reported on the Standard Version:  http://forums.puremvc.org/index.php?topic=490.0

It will be fixed at the same time. Since it is easy to work around, I've been awaiting other bugs to accompany it in a fix-fest, but none have cropped up so another release should happen shortly.

-=Cliff>


Title: Re: [FIXED] removeMediator is it a bug?
Post by: puremvc on April 06, 2009, 03:48:37
Sorry, forgot to mention this was fixed in the last version.
-=Cliff>