Vaadin8 - Cleaning up Registrations to a DataProvider

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).

I hope I understood the questions correctly. If you are setting the same DataProvider to all of your components, the components will stop listening to the data provideres updates when you detach the component from the UI component tree. Every component using a DataProvider is handling the communication from DataProvider to client side via the DataCommunicator, which is per each component, and detached together with each component. When you set a DataProvider to a component, the DataCommunicator starts listening to data update events from the provider.

When you have updates to a UI, even from the DataProvider, you should lock the session and then do the updates. So when you’re SingletonDataProvider fires the events from a backgroud thread or to other sessions, it should lock those first. If you have PushMode.AUTOMATIC on instead of MANUAL, do don’t need to push explicitly.

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.