Prevent UI-Updater to be null on page refresh

Hello Community,

I needed an infinite UI Updater, because I am building an chat. Because the Updater is ran asynchronously in a CompletableFuture, I had to get the UI from somewhere.

Unfortunately I found no other way than the following to get the UI in my layout class - the chat has to work in a [Tab]
(https://vaadin.com/components/vaadin-tabs), which is initialized by an AppLayout ([my function]
(https://pastebin.com/Vn7X73uW)), not sure if that’s the trigger…
The only way I could get it, was by start updating the chat in the
onAttach(AttachEvent attachEvent) function.

The problem is, when the page is restarted, the Updater gets interrupted because it is somehow null. I include the chat service using @Autowired. Do anyone have an solution?

Best Regards
Mats

Hi! If you are developing a chat, you should think about implementing the MQTT protocol for message logic, so you no longer have to refresh the site all the time.

Diego Ergui:
Hi! If you are developing a chat, you should think about implementing the MQTT protocol for message logic, so you no longer have to refresh the site all the time.

Sounds great! but how to use Polymer or Webcomponents? Haven’t found out until now

Oh! I really don’t know how to use MQTT with Polymer. I used it with an API Java (as Broker) and Vaadin 14 as client(s).

Diego Ergui:
Hi! If you are developing a chat, you should think about implementing the MQTT protocol for message logic, so you no longer have to refresh the site all the time.

I don’t have to refresh, @Push is doing well