Module is.codion.common.reactive
Interface Conditional<T>
- Type Parameters:
T- the observed value type
public interface Conditional<T>
Provides conditional listeners for an
Observer.
selection.item()
.when(Objects::nonNull)
.accept(this::onSelection);
state.when(true)
.run(this::onEnabled);
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceSpecifies what action to take on a given condition. -
Method Summary
Modifier and TypeMethodDescriptionSpecifies a predicate to determine when the action should be triggered.Specifies a value to trigger the action.
-
Method Details
-
when
Specifies a value to trigger the action. The action is triggered when the observed value equals the given value (usingObjects.equals(Object, Object)).- Parameters:
value- the value to react to (may be null)- Returns:
- an
Conditional.OnConditioninstance
-
when
Specifies a predicate to determine when the action should be triggered.- Parameters:
predicate- the predicate to test observed values against- Returns:
- an
Conditional.OnConditioninstance
-