Detaching UI

In my Vaadin 7 app, I have a UI.getCurrent().detach(). How do I do that in Flow?

There is UI.onDetach() in Flow. But the habit in Flow is to avoid overriding UI. So instead I recommend to observe onDetach(…) of your root layout, i.e. the layout which has @Route(“”), probably named MainLayout or something like that. Routes need to be unique and there can be only one @Route(“”) per UI.

Sorry, I guess I was not clear. I am NOT trying to override detach, I am trying to trigger detach. In other words, in my Vaadin 7 code, I call UI.getCurrent().detach() to force a detach so that my onDetach method will be called, and at the proper time. This is especially helpful when I want to close the UI in another browser tab, and I have special cleanup logic in my onDetach method that I want triggered once detaching happens. What I figured out with Vaadin 7 is that calling UI.getCurrent().close() did not work because the detaching did not happen until the user clicked on the tab, and then clicked somewhere on the web page. So how, in flow, do I do this same type of “detaching”, how do I TRIGGER a detach?

At, it says “You can make that occur quicker by making the UI heartbeat faster or immediately by using server push.”. This is very similar to what I want to do, actually. Maybe if there is an example out there of “immediately by using server push” of detach/closing a UI, that would help. The corresponding Vaadin 7 documentation somehow gave me the idea to call UI.getCurrent().detach() ( not that the Vaadin 7 documentation mentions calling detach explicitly, just got the idea from various places in the Vaadin 7 documentation ).

In case you are curious, here is a use case: on browser tabs 1 and 2, user is logged into same website, same session. User logs out of website on browser tab 1, then, in theory, they should also be closed out of the website in browser tab 2. Not closing the browser tab, of course, just forcing them back to the login screen on both tabs. Yes, not all websites would need such behavior, but ours does as it makes it a little more clear to the user, and makes some other behind the scenes things work a little better for us.

Maybe UI.close() is a better option for this? UI.detach() worked better in Vaadin 7, but maybe UI.close() will be good enough for Flow. Is that a correct assumption?