Package com.vaadin.flow.signals.function
Interface SignalModifier<P extends @Nullable Object,C extends @Nullable Object>
- Type Parameters:
P- the parent signal value typeC- the child (mapped) signal value type
- All Superinterfaces:
Serializable
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface
public interface SignalModifier<P extends @Nullable Object,C extends @Nullable Object>
extends Serializable
Modifies the parent signal value in place based on a new child value. Used
with the
ValueSignal.modifier(SignalModifier) helper method to create
write callbacks for mutable value patterns.
This interface is used with mutable value patterns where changing the child value directly modifies the parent value instance rather than creating a new one.
Usage example with a Todo class:
class Todo {
private String task;
private boolean done;
public String getTask() {
return task;
}
public void setTask(String task) {
this.task = task;
}
public boolean isDone() {
return done;
}
public void setDone(boolean done) {
this.done = done;
}
}
ValueSignal<Todo> todoSignal = new ValueSignal<>(new Todo());
textField.bindValue(todoSignal.map(Todo::getTask),
todoSignal.modifier(Todo::setTask));
checkbox.bindValue(todoSignal.map(Todo::isDone),
todoSignal.modifier(Todo::setDone));
- See Also:
-
Method Summary
-
Method Details
-
modify
Modifies the parent value in place with the new child value.- Parameters:
parentValue- the parent signal value to modifynewChildValue- the new child value to apply
-