Package com.vaadin.flow.signals.function
Interface SignalModifier<P,C>
- 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.
Modifies the parent signal value in place based on a new child value. Used
for creating two-way computed signals with mutable parent values where
changes to the mapped signal propagate back to the parent signal.
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.
Example usage with a mutable bean:
class Todo {
private String text;
private boolean done;
// getters and setters...
}
ValueSignal<Todo> todoSignal = new ValueSignal<>(
new Todo("Buy milk", false));
WritableSignal<Boolean> doneSignal = todoSignal.mapMutable(Todo::isDone,
Todo::setDone);
doneSignal.set(true); // Calls todoSignal.modify(t -> t.setDone(true))
- 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 modify, may benullnewChildValue- the new child value to apply, may benull
-