java.lang.Object
io.github.palexdev.materialfx.utils.others.observables.When<T>
io.github.palexdev.materialfx.utils.others.observables.OnChanged<T>
Concrete implementation of
When that uses ChangeListeners to
listen for changes for a given ObservableValue.
You can specify the action to perform when this happens using a BiConsumer,
then(BiConsumer).
To activate the construct do not forget to call listen() at the end.
IntegerProperty aNumber = new SimpleIntegerProperty(69);
When.onChanged(aNumber) // You can also use... OnChanged.forObservable(...)
.then((oldValue, newValue) -> System.out.println("Value switched from: " + oldValue + " to " + newValue))
.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 theOnChangedconstruct by removing theChangeListenerfrom theObservableValue, then sets the listener to null and finally removes the observable from the map.static <T> OnChanged<T>forObservable(ObservableValue<T> observableValue) Creates and instance of this construct for the givenObservableValue.listen()Activates theOnChangedconstruct with the previously specified parameters.then(BiConsumer<T, T> action) To set the action to perform when the specifiedObservableValuechanges.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 specifiedObservableValuechanges. The action is aBiConsumerthat carries both the old value and the new value of the observable. -
listen
Activates theOnChangedconstruct with the previously specified parameters. So, builds theChangeListeneraccording to theWhen.isOneShot()parameter, then adds the listener to the specifiedObservableValueand finally puts the Observable and the OnChanged construct in the map. -
dispose
public void dispose()Disposes theOnChangedconstruct by removing theChangeListenerfrom theObservableValue, then sets the listener to null and finally removes the observable from the map.
-