Vaadin 14 - Listener for "OnCloseBrowserTab"

Hello,

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?

Hi,

You can check this add-on https://vaadin.com/directory/component/superfields

There is a UnloadObserver that could help you.

There is also a closed ticket here: https://github.com/vaadin-miki/super-fields/issues/170 with the same kind of need

thanks!

The UnloadObserver solution looks very good.