Monday, August 31, 2020

Re: Experiences using event bus

My favorite for EventBus is this framework: https://github.com/google/gwteventbinder 

In combination with the video, IMHO is the easiest framework for EventBus: Google I/O 2013 - Demystifying MVP and EventBus in GWT

Gordan Krešić schrieb am Samstag, 29. August 2020 um 11:21:03 UTC+2:
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/0fc1ad95-3d46-4d58-88f2-0acc27cb005an%40googlegroups.com.

No comments:

Post a Comment