I would like to ask for any advice/idea on how to use event buses in GWT. So far I'm using GWT's own com.google.gwt.event.shared.EventBus, but wouldn't have issues migrating to other implementations.

My concern goes to very cumbersome and error prone handling when to unregister subscribers to allow them to be garbage collected. I'm aware of ResettableEventBus, but it doesn't solve problems when I don't have clear events to unregister whole classes of subscribers (if I'm not mistaken, it was designed to be used inside single Activity and unregister all subscribers when activity stops, but that flow doesn't work for me, because I need subscribers active even when they are not in current activity).

When possible, I'm subscribing to events in "onLoad" event and unsubscribing in "onUnload", but that also doesn't work in not-that-uncommon corner cases when I need subscribers active even when detached from DOM.

Only "solution" that works is manually unregistering when I'm sure subscriber is going away, but as I said, that is very error prone (and beats the purpose of having a garbage collected language).

WeakReference(s) are not supported. Is there any implementation trying to utilize JS's WeakMap?

Any other ideas?

        -gkresic.

--
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit/f10fc578-8096-0109-9b7b-a27cdd3fac8f%40steatoda.com.

Reply via email to