Interface SignalModifier<P,C>

Type Parameters:
P - the parent signal value type
C - 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,C> extends Serializable
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

    Modifier and Type
    Method
    Description
    void
    modify(P parentValue, C newChildValue)
    Modifies the parent value in place with the new child value.
  • Method Details

    • modify

      void modify(P parentValue, C newChildValue)
      Modifies the parent value in place with the new child value.
      Parameters:
      parentValue - the parent signal value to modify, may be null
      newChildValue - the new child value to apply, may be null