Package com.vaadin.flow.dom
Class SignalBinding<T extends @Nullable Object>
java.lang.Object
com.vaadin.flow.dom.SignalBinding<T>
- Type Parameters:
T- the type of the bound signal value
- All Implemented Interfaces:
Serializable
Represents an active binding between a signal and an element property (text,
attribute, visibility, etc.). Provides the ability to register callbacks that
are invoked whenever the binding updates, with rich context about the update.
Typical usage:
span.bindText(signal).onChange(ctx -> {
if (ctx.isBackgroundChange()) {
ctx.getElement().flashClass("highlight");
}
});
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionGets the registration that controls the lifecycle of the underlying effect.onChange(SerializableConsumer<BindingContext<T>> action) Registers a callback that is invoked every time the bound signal value changes and the binding updates the element.
-
Method Details
-
getEffectRegistration
Gets the registration that controls the lifecycle of the underlying effect. Removing the registration stops the effect from running.For internal use only. May be renamed or removed in a future release.
- Returns:
- the effect registration, or
nullif not set
-
onChange
Registers a callback that is invoked every time the bound signal value changes and the binding updates the element. The callback receives aBindingContextthat provides the old value, new value, target element, nearest component, and whether the change was a background update, initial render, or user-triggered.Multiple callbacks can be registered by calling this method multiple times. All registered callbacks are invoked in registration order.
Example:
span.bindText(signal).onChange(ctx -> { if (ctx.isBackgroundChange()) { ctx.getElement().flashClass("highlight"); } });- Parameters:
action- the callback to invoke on each update, notnull- Returns:
- this binding for fluent chaining
-