Module MaterialFX
Class OnInvalidated<T>
java.lang.Object
io.github.palexdev.materialfx.utils.others.observables.When<T>
io.github.palexdev.materialfx.utils.others.observables.OnInvalidated<T>
Concrete implementation of
When that uses InvalidationListeners to
listen for changes for a given ObservableValue.
You can specify the action to perform when this happens using a Consumer,
then(Consumer).
To activate the construct do not forget to call listen() at the end.
BooleanProperty aSwitch = new SimpleBooleanProperty(false);
When.onInvalidated(aSwitch) // You can also use... OnInvalidated.forObservable(...)
.then(value -> System.out.println("Value switched to: " + value))
.oneShot()
.listen();
-
Field Summary
Fields inherited from class io.github.palexdev.materialfx.utils.others.observables.When
observableValue, oneShot, whens -
Method Summary
Modifier and TypeMethodDescriptionvoiddispose()Disposes theOnInvalidatedconstruct by removing theInvalidationListenerfrom theObservableValue, then sets the listener to null and finally removes the observable from the map.static <T> OnInvalidated<T>forObservable(ObservableValue<T> observableValue) Creates and instance of this construct for the givenObservableValue.listen()Activates theOnInvalidatedconstruct with the previously specified parameters.To set the action to perform when the specifiedObservableValuebecomes invalid.Methods inherited from class io.github.palexdev.materialfx.utils.others.observables.When
disposeFor, isOneShot, onChanged, oneShot, onInvalidated
-
Method Details
-
forObservable
Creates and instance of this construct for the givenObservableValue. -
then
To set the action to perform when the specifiedObservableValuebecomes invalid. The action is aConsumerthat carries the new value of the observable. -
listen
Activates theOnInvalidatedconstruct with the previously specified parameters. So, builds theInvalidationListeneraccording to theWhen.isOneShot()parameter, then adds the listener to the specifiedObservableValueand finally puts the Observable and the OnInvalidated construct in the map. -
dispose
public void dispose()Disposes theOnInvalidatedconstruct by removing theInvalidationListenerfrom theObservableValue, then sets the listener to null and finally removes the observable from the map.
-