PureMVC Architects Lounge

PureMVC Manifold => Standard Version => Topic started by: dd on July 05, 2010, 07:39:48



Title: Should a mediator/proxy/command be able to send notifications after removal?
Post by: dd on July 05, 2010, 07:39:48
I've come across the following scenario: register proxy, the proxy makes some asynchronous service calls but while waiting for those calls, the user changes the view in such way that the proxy is not needed anymore so we remove it from the facade. Then the response from the server comes, proxy gets the data and sends notification that it has loaded some data, although it is no longer registered with the facade. Should this behavior be possible? What scenarios would require it?

PS: I know that in an ideal world, the proxy would cancel all the calls the moment it got removed from the facade, however time constraints lead to little monsters like these...


Title: Re: Should a mediator/proxy/command be able to send notifications after removal?
Post by: puremvc on July 05, 2010, 09:40:11
The reason that the Proxy is still able to send the note is that it still has a reference to the Facade even though it's been removed from the Model. It would ordinarily be available for GC after being removed from the Model if there are no other references to it, but it has added event listeners to the service, which then has a reference back to the Proxy.

In the onRemove method of the Proxy, you should cancel any calls, remove service event listeners and null the service component reference. Then, if nothing else has a reference to the Proxy, you should hear no more from it when you remove it.

-=Cliff>