I am using the MVP template from my GWT application, following the example here http://code.google.com/webtoolkit/doc/latest/tutorial/mvp-architecture.html
I have one MainPresenter and a sub-presenter for each of the panels in MainView. To show a new sub-presenter, I am doing something like this:
presenter = new PresenterA(new ViewA(), ....); presenter.go(panel)
When PresenterA is created, it binds to events in ViewA . The question is, how to switch to the new leader? Right now, I'm just creating a new presenter and attaching it to the same panel as this:
presenter = new PresenterB(new ViewB(), ....); presenter.go(panel)
I have some doubts about this approach. First, do I cause a memory leak when switching to a new master? I lost the field that refers to the old presenter and cleared it of the panel to which it was attached. I suppose that means garbage collection, but I'm not sure. Secondly, what happens to the event bindings that the old presenter had? Will these bindings prevent the lead from being garbage collected? Do I need to untie them first?
What is the correct way to handle the situation of switching presenters without memory leaks and binding to "dead" events.
java javascript memory-leaks mvp gwt
user27478
source share