Tuesday, September 1, 2020

Re: Experiences using event bus


If I'm looking at it correctly, it provides just syntactic sugar on top of
GWT's own EventBus, right?

Thats true,´.
 
 From what I can see, problem with "ghost" references in event bus which
would prevent subscribed objects from being garbage collected is still there.

Right.

But what I don't get is why you don't want to explicitly clean things up? If you rely on WeakRef or anything similar you depend on garbage collection, which isn't really great since you never know when GC will happen and behavior is different between browsers. So if you have an EventBus that uses some weak references it is likely designed as "if nobody has a strong reference to a registered event handler, then remove that event handler from the event bus". The problem is that you can not control GC and as long as GC does not run, these handlers will still get events, regardless if your app still uses these classes or not. So you have overhead until the browser decides to run GC and clean these weak references.

I would try to refactor code to make explicit event bus registration and deregistration easier and less error prone. For example take GWT Activities. The EventBus you get in its start() method is automatically cleaned up as soon as the activity stops. I am pretty sure there are options to build some classes around your existing ones to better deal with EventBus.

-- J.

--
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/442289b4-ad32-4018-8ac3-04d32d71a5b9o%40googlegroups.com.

1 comment:

  1. You actually make it seem so easy with your presentation but I find this topic to be really something which I think I would never understand. It seems too complicated and extremely broad for me. I’m looking forward to your next post, I will try to get the hang of it!
    skip bin hire brisbane
    skip bin hire darra

    ReplyDelete