Class SignalBindingFeature
java.lang.Object
com.vaadin.flow.internal.nodefeature.NodeFeature
com.vaadin.flow.internal.nodefeature.ServerSideFeature
com.vaadin.flow.internal.nodefeature.SignalBindingFeature
- All Implemented Interfaces:
Serializable
Node feature for binding
Signals to various properties of a node.
For internal use only. May be renamed or removed in a future release.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a SignalBindingFeature for the given node. -
Method Summary
Modifier and TypeMethodDescriptionGets the signal bound to the given key.<T> @Nullable SerializableConsumer<T> getWriteCallback(String key) Gets the write callback for the given key.booleanhasAnyBinding(String keyPrefix) Checks whether there is any binding with a key starting with the given prefix.booleanhasBinding(String key) Checks whether there is a binding for the given key.voidsetBinding(String key, Signal<?> signal) Sets a binding for the given key.voidsetBinding(String key, Signal<?> signal, @Nullable SerializableConsumer<?> writeCallback) Sets a binding for the given key with a write callback.<T extends @Nullable Object>
booleanupdateSignalByWriteCallback(String key, T oldValue, T newValue, SerializableBiPredicate<T, T> valueEquals, SerializableConsumer<T> revertCallback) Updates the signal value by invoking the write callback for the given key.Methods inherited from class com.vaadin.flow.internal.nodefeature.ServerSideFeature
collectChanges, forEachChild, generateChangesFromEmptyMethods inherited from class com.vaadin.flow.internal.nodefeature.NodeFeature
allowsChanges, attachPotentialChild, detatchPotentialChild, getNode, onAttach, onDetach
-
Field Details
-
TEXT
- See Also:
-
CLASSES
- See Also:
-
CLASS_GROUP
- See Also:
-
ENABLED
- See Also:
-
VALUE
- See Also:
-
THEMES
- See Also:
-
THEME_GROUP
- See Also:
-
HTML_CONTENT
- See Also:
-
CHILDREN
- See Also:
-
ITEMS
- See Also:
-
-
Constructor Details
-
SignalBindingFeature
Creates a SignalBindingFeature for the given node.- Parameters:
node- the node which supports the feature
-
-
Method Details
-
setBinding
Sets a binding for the given key.- Parameters:
key- the keysignal- the signal
-
setBinding
public void setBinding(String key, Signal<?> signal, @Nullable SerializableConsumer<?> writeCallback) Sets a binding for the given key with a write callback.- Parameters:
key- the keysignal- the signalwriteCallback- the callback to propagate value changes back, ornullfor a read-only binding
-
hasBinding
Checks whether there is a binding for the given key.- Parameters:
key- the key- Returns:
- true if there is a binding for the given key, false otherwise
-
hasAnyBinding
Checks whether there is any binding with a key starting with the given prefix.- Parameters:
keyPrefix- the key prefix- Returns:
- true if there is any binding with a key starting with the given prefix, false otherwise
-
getWriteCallback
Gets the write callback for the given key.- Type Parameters:
T- the type of the consumer value- Parameters:
key- the key- Returns:
- the write callback for the given key, or null if no callback is set
-
getSignal
Gets the signal bound to the given key.- Type Parameters:
T- the type of the signal value- Parameters:
key- the key- Returns:
- the signal bound to the given key, or null if no signal is bound
-
updateSignalByWriteCallback
public <T extends @Nullable Object> boolean updateSignalByWriteCallback(String key, T oldValue, T newValue, SerializableBiPredicate<T, T> valueEquals, SerializableConsumer<T> revertCallback) Updates the signal value by invoking the write callback for the given key. The callback is expected to update the signal value, and this method will check whether the signal value was updated to the expected new value. If the signal value differs from the expected new value after the callback, the revert callback will be invoked with the current signal value to revert the change.- Type Parameters:
T- the type of the signal value- Parameters:
key- the key for which to update the signal valueoldValue- the old value before the update, used for comparison in case of revertnewValue- the expected new value to be set by the write callbackvalueEquals- a predicate to compare signal values for equalityrevertCallback- a callback to revert the component value to the updated signal's value if the signal value does not match the expected new value after invoking the write callback- Returns:
- true if the signal value was updated to the expected new value, false if a revert was performed
-