Class ValBase<T>

java.lang.Object
org.reactfx.ObservableBase<Consumer<? super T>,T>
org.reactfx.value.ValBase<T>
All Implemented Interfaces:
javafx.beans.Observable, javafx.beans.value.ObservableValue<T>, Observable<Consumer<? super T>>, ProperObservable<Consumer<? super T>,T>, ProperVal<T>, Val<T>
Direct Known Subclasses:
AnimatedVal, FlatMapped, ListReduction, MappedVal, OrElse, OrElseConst, SimpleVar, SuspendableBoolean, ValWrapper

public abstract class ValBase<T> extends ObservableBase<Consumer<? super T>,T> implements ProperVal<T>
  • Field Details

    • valid

      private boolean valid
    • value

      private T value
  • Constructor Details

    • ValBase

      public ValBase()
  • Method Details

    • getValue

      public final T getValue()
      Specified by:
      getValue in interface javafx.beans.value.ObservableValue<T>
    • observeInputs

      protected final Subscription observeInputs()
      Description copied from class: ObservableBase
      Starts observing this observable's input(s), if any. This method is called when the number of observers goes from 0 to 1. This method is called before ObservableBase.newObserver(Object) is called for the first observer.
      Specified by:
      observeInputs in class ObservableBase<Consumer<? super T>,T>
      Returns:
      subscription used to stop observing inputs. The subscription is unsubscribed (i.e. input observation stops) when the number of observers goes down to 0.
    • invalidate

      protected final void invalidate()
    • newObserver

      protected final void newObserver(Consumer<? super T> oldValueObserver)
      Description copied from class: ObservableBase
      Called for each new observer. Overriding this method is a convenient way for subclasses to handle this event, for example to publish some initial events.

      This method is called after the ObservableBase.observeInputs() method.

      Overrides:
      newObserver in class ObservableBase<Consumer<? super T>,T>
    • connect

      protected abstract Subscription connect()
      Implementation of this method should start observing inputs. If the value of this Val may change as a result of input change, the corresponding input observer should call invalidate() to notify observers of this Val. By the time of calling invalidate(), the input observer must have already updated any internal state of this Val, so that a subsequent call to computeValue() returns the current value of this Val.
      Returns:
      Subscription that can be used to stop observing inputs.
    • computeValue

      protected abstract T computeValue()