flow
flow copied to clipboard
Add method in Router to run callback after before leave confirmation.
Describe your motivation
In Vaadin 8 it is possible to run call back after before leave confirmed. This is handy for example with in case of logout button. See code example below.
var logout = new MenuBar();
logout.setId("logout");
var item = logout.addItem(getTranslation(LOGOUT), e -> {
// Use runAfterLeaveConfirmation wrapper to run the logout in based
// on beforeLeave of the current view.
nav.runAfterLeaveConfirmation(() -> {
logger.info("User '{}' logout",
CurrentUser.get().get().getName());
ui.getSession().getSession().invalidate();
ui.getPage().reload();
});
});
Describe the solution you'd like
It would be preferable a method with similar naming in convenient place. This would help migrating Vaadin 8 application using this API.
Additional context
In addition to helping the migration from Vaadin 8, the method could be useful as is.