Vaadin 14 - Listener for "OnCloseBrowserTab"


I’m looking for a solution to detect closing a BrowserTab window.

I use the annotation @Push. As a result, the web socket connection is always closed as soon as the Borwser
closes or the page is reloaded by F5.

If the web socket connection is terminated, the AtmospherePushConnection.connectionLost() method is called.
I would like a listener if the value of AtmospherePushConnection.State changes.

Is there a solution for this?


You can check this add-on

There is a UnloadObserver that could help you.

There is also a closed ticket here: with the same kind of need


The UnloadObserver solution looks very good.