aboutsummaryrefslogtreecommitdiffstats
path: root/shared
diff options
context:
space:
mode:
Diffstat (limited to 'shared')
-rw-r--r--shared/src/main/java/com/vaadin/shared/ui/ComponentStateUtil.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/shared/src/main/java/com/vaadin/shared/ui/ComponentStateUtil.java b/shared/src/main/java/com/vaadin/shared/ui/ComponentStateUtil.java
index a38b828471..bcc4b3f496 100644
--- a/shared/src/main/java/com/vaadin/shared/ui/ComponentStateUtil.java
+++ b/shared/src/main/java/com/vaadin/shared/ui/ComponentStateUtil.java
@@ -19,6 +19,7 @@ import java.io.Serializable;
import java.util.HashSet;
import com.vaadin.shared.AbstractComponentState;
+import com.vaadin.shared.Registration;
import com.vaadin.shared.communication.SharedState;
public final class ComponentStateUtil implements Serializable {
@@ -57,7 +58,11 @@ public final class ComponentStateUtil implements Serializable {
*
* @param eventListenerId
* The event identifier to remove
+ * @deprecated Use a {@link Registration} object returned by
+ * {@link #addRegisteredEventListener(SharedState, String)} to
+ * remove a listener
*/
+ @Deprecated
public static final void removeRegisteredEventListener(SharedState state,
String eventIdentifier) {
if (state.registeredEventListeners == null) {
@@ -74,12 +79,14 @@ public final class ComponentStateUtil implements Serializable {
*
* @param eventListenerId
* The event identifier to add
+ * @return a registration object for removing the listener
*/
- public static final void addRegisteredEventListener(SharedState state,
- String eventListenerId) {
+ public static final Registration addRegisteredEventListener(
+ SharedState state, String eventListenerId) {
if (state.registeredEventListeners == null) {
state.registeredEventListeners = new HashSet<>();
}
state.registeredEventListeners.add(eventListenerId);
+ return () -> removeRegisteredEventListener(state, eventListenerId);
}
}