LanDanois
LanDanois

Reputation: 95

RemoveEventListener click vaadin

I have the following code:

label.getElement().addEventListener("click", e->{
            System.out.print("\nHello there\n");
        });

But my app will, at times, add a different click listener to the same label. In some other frameworks, like android (the vaadin button acts the same), adding a second listener would remove the old one. However, in this case it does not.

How would I go about removing the listener in this case. So I only have a single click listener.

Upvotes: 0

Views: 2118

Answers (1)

Leif Åstrand
Leif Åstrand

Reputation: 8001

The addEventListener method returns a DomListenerRegistration instance that you can use later on to remove that specific listener (using the remove() method).

Vaadin doesn't offer any way of removing all listeners.

Upvotes: 3

Related Questions