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 / Bug Report / [FIXED] removeMediator is it a bug? 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.
Pages: [1]