Implementation:
In a flat mapped binding there are always two subscriptions involved:
The subscription on the indirect source must change whenever the value of the given source changes or is invalidated. More specifically, when the given source is invalidated the indirect subscription should be removed, and when it is revalidated it should resubscribe to the newly calculated indirect source. The binding avoids resubscribing when only the value of the indirect source changes.
| Modifier and Type | Field and Description |
|---|---|
| private ObservableValue | |
| private Subscription | |
| private final Function | |
| private final ObservableValue |
| Access | Constructor and Description |
|---|---|
| public | FlatMappedBinding(ObservableValue<S> source, Function<? super S, ? extends ObservableValue<? extends T>> mapper)
|
| Modifier and Type | Method and Description |
|---|---|
| protected T | computeValue()
Implements abstract javafx. Calculates the current value of this binding. |
| private void | |
| protected Subscription | observeSources()
Implements abstract com. Called when this binding was previously not observed and a new observer was added. |
| private void |
| indirectSource | back to summary |
|---|---|
| private ObservableValue<? extends T> indirectSource | |
| indirectSourceSubscription | back to summary |
|---|---|
| private Subscription indirectSourceSubscription | |
| mapper | back to summary |
|---|---|
| private final Function<? super S, ? extends ObservableValue<? extends T>> mapper | |
| source | back to summary |
|---|---|
| private final ObservableValue<S> source | |
| FlatMappedBinding | back to summary |
|---|---|
| public FlatMappedBinding(ObservableValue<S> source, Function<? super S, ? extends ObservableValue<? extends T>> mapper) | |
| computeValue | back to summary |
|---|---|
| protected T computeValue() Implements abstract javafx. Doc from javafx. Calculates the current value of this binding.
Classes extending
| |
| invalidateAll | back to summary |
|---|---|
| private void invalidateAll() Called when the primary source changes. Invalidates this binding and unsubscribes the indirect source
to avoid holding a strong reference to it. If the binding becomes valid later, Note that this only needs to be called for changes of the primary source; changes in the indirect source only need to invalidate this binding without also unsubscribing, as it would be wasteful to resubscribe to the same indirect source for each invalidation of that source. | |
| observeSources | back to summary |
|---|---|
| protected Subscription observeSources() Implements abstract com. Doc from com. Called when this binding was previously not observed and a new observer was added. Implementors must return a
| |
| unsubscribeIndirectSource | back to summary |
|---|---|
| private void unsubscribeIndirectSource() | |