Over 10 years of community discussion and knowledge are maintained here as a read-only archive.
var mediator:MyMediator; mediator = facade.removeMediator(MyMediator.NAME); mediator.destroy();
8. Remove unused MediatorsIn some cases you don’t use a Mediator and its View Components anymore. Then remove the Mediator using facade.removeMediator(MyMediator.NAME); in conjunction with a self created destroy() method to remove the ViewComponent including all listeners, timer, references, etc. for a successful garbage collection.
My concern with every suggestion for framework change is striking the balance between the opposing perceptions of full-featuredness for advanced users and overwhelming and daunting to new users.
public interface IDisposable { function dispose():void; }
public class MyMediator extends Mediator implements IMediator, IDisposable { ... public function dispose():void { viewComponent.removeEventListener(Event, function); ... } ... }
public class RemoveAndDisposeCommand extends SimpleCommand implements ICommand { override public function execute(notification:INotification):void { var mediatorName:String = notification.getBody() as String; var toDestroy:IDisposable = facade.removeMediator(mediatorName) as IDisposable; if (toDestroy != null) toDestroy.dispose(); } }
sendNotification(ApplicationFacade.REMOVE_AND_DISPOSE, mediatorName);