How to detect when user switch tab in browser

Hi,

I have a problem with my application:
I’m automatically refreshing some of the components from server side, but when, for example in chrome, I switch to another tab, data stop being refreshed. Then when I return about five minutes later, all requests are trying to be solved at once. That makes the application freeze and even reload takes a long time. So I need some way to detect when user switches tabs so I can stop sending update requests. Or any other solution that would solve my problem. Any help would be appreciated.

Thanks

Martin

Hi, how do you refresh your components? If you are using Server Push to do the refreshing (https://vaadin.com/docs/v14/flow/advanced/tutorial-push-access.html), then it shouldn’t matter whether or not the tab is focused in the browser.