Of course in the old world of manually managing listener collections,
one had to do it, but in the new world of HandlerManagers?
But it certainly isn't required.
There's a reason why the handler manager goes to the trouble of
returning a handler registration. There's no way for it to know that
you're done with the handler. This is one of those cases where garbage
collection wouldn't even help you because the handler manager has to
hold a reference to the handler (unless you use weak references, but
I'm pretty sure we don't have those in the JDK emulation layer).
It's not too difficult to keep track of handler registrations. I often
make a collection to hold them. Just add them all to the collection in
your bind method and unregister everything (and clear the collection)
in your unbind method.
-Brian
I already ran into some of issues according handlers I missed to
unbind. Therefore it would be nice to find a way to avoid this
destructor-like (java uncommon) coding pattern. I think there should
be an easy way, but actually I haven't had enough time to figure it
out yet and provide an idea for a soultion.
This is not the case if you are using a global handler manager for say
an event bus. If handlers are added that are specific to a particular
presenter then the presenter needs to remove the handlers when it is
destroyed. I implemented a Place Manager that takes care of all of
this automatically along with history support.