Vaadin 8 remove valuechange listeners

Hey,

How can I remove a valuechangelistener from an abstract field in vaadin 8?
In vaadin 7 I did.
if (c instanceof AbstractField){
listeners = (Collection) ((AbstractField) c).getListeners(ValueChangeEvent.class);
for (ValueChangeListener liste: listeners){
((AbstractField) c).removeValueChangeListener(liste);
}
}

Best regards,

Filos

My understanding is that the HasValue.addValueListener(HasValue.ValueChangeListener) method returns a Registration instance; to remove the listener you call the remove() method on the Registration object.
It would be useful if someone could explain the rationale behind this decision: at first sight it hides a simple, clear method call behing an interface, it breaks symmetry (add/remove) and means you have to keep a reference to yet another object (Registration) when you already have one to the listener and the “listened to”.

Hey Normand,

Thanks for your reply!
I was hoping I was wrong about it. But I think you are right and we need to hold a refence to the listener/registration.
Is it possible to add an object to a component?

Best regards,

Pluto

Any update on this?