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

Pages: [1]
Print
Author Topic: Should a mediator/proxy/command be able to send notifications after removal?  (Read 7766 times)
dd
Newbie
*
Posts: 4


View Profile Email
« 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...
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 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>
Logged
Pages: [1]
Print