目前我正在开发 flex 应用程序,我正在使用 puremvc 的多核变体。我的问题是在我的代理中,我正在进行远程调用并附加一些(RESULT 和 FAULT)事件侦听器。因此,在我的事件处理程序代码中,我是否应该明确删除侦听器以使 remoteObject 类有资格进行垃圾收集?
public function getTableGridData():void
{
var hostController:RemoteObject=this.hostController("ABC");
hostController.addEventListener(ResultEvent.RESULT, handleResult);
hostController.addEventListener(FaultEvent.FAULT, handleFault);
hostController.getTableData();
}
private function handleResult(event:ResultEvent):void
{
ApplicationFacade.getInstance(key).sendNotification("abc", event.result);
}
所以这里 hostController 持有两个监听器的强引用。因此,在 resultEvent 之后 hostController 是否有资格进行垃圾收集,或者我必须为侦听器提及弱参考以使 hostController 有资格进行垃圾收集?