Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Vaadin8 - Cleaning up Registrations to a DataProvider

Jean-François Lamy
6 years ago Feb 26, 2017 4:44pm

I have a scenario where I want to listen to updates to a shared, application-wide, complicated-and-expensive singleton DataProvider from many components (including ones I write, not only Listings) displayed in many UI and many Sessions.  In the circa-2009 Vaadin6 days, I was very careful to remember all my listeners in each UI, so that I could free the references when the users closed browser windows.

  1. I am currently relearning Vaadin8 and using SpringBoot+VaadinSpring.  Do I still need to do this sort of magic and implement listener cleanup code in ViewChangeListeners and the like, or are listeners magically scoped and cleaned up ? 
  2. I used to force a push in my previous design.  Does the new DataProvider-to-Component magic relieve me from doing this -- will the various listening UIs refresh without me doing anything, or will there be a lag until something is actually done on the client browsers if I don't push (I would expect that I need to enable autopushing).
Pekka Hyvönen
6 years ago Mar 07, 2017 2:44pm
Jean-François Lamy
6 years ago Mar 10, 2017 6:13pm

Not quite clear where the programmer can lock the UI.

In the old way of doing things a background thread updates the data source under the containers at time t=0. Then at t=1 I broadcast an event telling all the listeners that an update has taken place.   At t=2 an event listener method on a listening UI is invoked.  The UI is locked at t=3 and the component is refreshed safely.

In the new world, there is a DataCommunicator, which at t=0 has already told its subscribing components to update.  The only way I can see this working is that Vaadin has its own internal data communication broadcast mechanism, and that it locks the UI iself.

I don't see where the programmer could intervene to lock the UI unless there is a hook/event just prior to a component being updated by its DataCommunicator.