Package org.reactfx.value
Class ValBase<T>
- java.lang.Object
-
- org.reactfx.ObservableBase<java.util.function.Consumer<? super T>,T>
-
- org.reactfx.value.ValBase<T>
-
- All Implemented Interfaces:
javafx.beans.Observable
,javafx.beans.value.ObservableValue<T>
,Observable<java.util.function.Consumer<? super T>>
,ProperObservable<java.util.function.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<java.util.function.Consumer<? super T>,T> implements ProperVal<T>
-
-
Constructor Summary
Constructors Constructor Description ValBase()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract T
computeValue()
protected abstract Subscription
connect()
Implementation of this method should start observing inputs.T
getValue()
protected void
invalidate()
protected void
newObserver(java.util.function.Consumer<? super T> oldValueObserver)
Called for each new observer.protected Subscription
observeInputs()
Starts observing this observable's input(s), if any.-
Methods inherited from class org.reactfx.ObservableBase
addObserver, enqueueNotifications, equals, forEachObserver, getObserverCount, hashCode, isObservingInputs, notifyObservers, notifyObservers, observe, removeObserver, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.reactfx.Observable
addObserver, observe, removeObserver
-
Methods inherited from interface org.reactfx.ProperObservable
defaultEquals, defaultHashCode, defaultToString, notifyObservers
-
Methods inherited from interface org.reactfx.value.ProperVal
defaultNotificationAccumulator
-
Methods inherited from interface org.reactfx.value.Val
addInvalidationObserver, addListener, addListener, animate, animate, asList, asVar, changes, conditionOn, conditionOnShowing, filter, flatMap, getOpt, getOrElse, getOrSupply, getOrThrow, ifPresent, invalidations, isEmpty, isPresent, map, mapDynamic, observeChanges, observeInvalidations, orElse, orElseConst, pin, removeInvalidationObserver, removeListener, removeListener, selectVar, selectVar, suspendable, values
-
-
-
-
Field Detail
-
valid
private boolean valid
-
value
private T value
-
-
Method Detail
-
getValue
public final T getValue()
- Specified by:
getValue
in interfacejavafx.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 beforeObservableBase.newObserver(Object)
is called for the first observer.- Specified by:
observeInputs
in classObservableBase<java.util.function.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(java.util.function.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 classObservableBase<java.util.function.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 callinvalidate()
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 tocomputeValue()
returns the current value of this Val.- Returns:
- Subscription that can be used to stop observing inputs.
-
computeValue
protected abstract T computeValue()
-
-