com.vaadin.flow.shared.
Interface Registration
All Superinterfaces:
All Known Subinterfaces:
DomListenerRegistration
, ReturnChannelRegistration
, StateTree.ExecutionRegistration
All Known Implementing Classes:
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A registration object for removing an event listener added to a source.
Since:
1.0
Author:
Vaadin Ltd
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Registration
addAndRemove
(Collection<T> collection, T item) Creates a registration by adding an item to a collection immediately and removing the item from the collection when the registration is removed.
static Registration
combine
(Registration... registrations) Creates a registration that will remove multiple registrations.
static Registration
Creates a registration that will run a command only once.
void
remove()
Removes the associated listener from the event source.
-
Method Details
-
remove
void remove()Removes the associated listener from the event source.
The
remove
method called after removal does nothing.See Also:
-
once
Creates a registration that will run a command only once. This makes it safe for the registration to be removed multiple times even in cases when the command should be run only once.
Parameters:
command
- the command to run the first time the registration is removed, notnull
Returns:
a registration that will invoke the command once, not
null
Since:
-
addAndRemove
Creates a registration by adding an item to a collection immediately and removing the item from the collection when the registration is removed.
Care should be used when using this pattern to iterate over a copy of the collection to avoid
ConcurrentModificationException
if a listener or other callback may trigger adding or removing registrations.Parameters:
collection
- the collection to which the item should be added and removed, notnull
item
- the item to add and removeReturns:
a registration that will remove the item from the collection, not
null
Since:
-