Skip to content

Commit

Permalink
#173 allowed explicit removing of the thread-local instance
Browse files Browse the repository at this point in the history
  • Loading branch information
vaadin-miki committed Jun 25, 2020
1 parent 516de9e commit d0a831e
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ public static UnloadObserver get(boolean queryingOnUnload) {
return INSTANCES.get();
}

/**
* Cleans up the thread-local variable. This method should be called when the unload observer is no longer needed.
*/
public static void remove() {
if(INSTANCES.get() != null)
INSTANCES.remove();
}

private boolean queryingOnUnload;

private boolean clientInitialised;
Expand Down Expand Up @@ -152,5 +160,4 @@ protected void fireUnloadEvent(UnloadEvent event) {
public Registration addUnloadListener(UnloadListener listener) {
return this.getEventBus().addListener(UnloadEvent.class, listener);
}

}

0 comments on commit d0a831e

Please sign in to comment.