IndirectObservableValue

open class IndirectObservableValue<P : Any, V>(val parentProperty: ObservableValue<P>, val getObservable: (P) -> ObservableValue<V>) : LazyObservableValue<V>

Tracks a value of a property where we don't have the property itself, but only another property, (parentProperty) from which we can access the required property.

Imagine we have a class Person, with : val nameProperty : StringProperty

Now suppose we have :

val personProperty : Property

Note that personProperty.value can be null.

The following will give us an ObservableValue which changes whenever personProperty changes, and also changes whenever that person's name changes.

val personNameProperty : ObservableValue = IndirectObservableValue( personProperty, "" ) {
    person -> person.nameProperty.value
}

When personProperty.value == null, then personNameProperty.value == "<None>", not null.

Alas, personNameProperty is not of type ObservableString. To work around the JVM's limited type system, consider creating a boilerplate class :

class IndirectObservableString

( parentProperty: ObservableValue, defaultValue: String, getObservable: (P) -> ObservableValue ) : IndirectObservableValue(parentProperty, defaultValue, getObservable), ObservableString

Inheritors

Constructors

Link copied to clipboard
constructor(parentProperty: ObservableValue<P>, getObservable: (P) -> ObservableValue<V>)

Properties

Link copied to clipboard

A lambda to get the ObservableValue we are interested in tracking, from the value of parentProperty.

Link copied to clipboard

Functions

Link copied to clipboard
open override fun eval(): V