ObservableValue

Holds a value of type V, which can be observed using InvalidationListeners. When the value changes, the InvalidationListeners are informed via InvalidationListener.invalidated.

Property is a notable sub-interface, whose value is mutable. They have ChangeListeners (similar to InvalidationListener, but are also sent the old value and newValue.

Note. It is common to name an ObservableValue xxxProperty, even though it isn't really a Property. For example, suppose we have a Rectangle class, with left, right and width ObservableValues. We could choose to store left and right as Properties, with width as a BinaryFunction. Or we could store left and width as Properties, with right as a BinaryFunction. No matter which we choose, it is acceptable to name them leftProperty, rightProperty and widthProperty, despite one of them not inheriting from Property.

                                              ╭╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╮
                                              ┆     Observable    ┆
                                              ┆ addListener()     ┆
                                              ┆ removeListener()  ┆
                                              ╰╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╯
                                                        △
                               ┌────────────────────────┴──┬────────────────┐
                  ╭╌╌╌╌╌╌╌╌╌╌╌╌┴╌╌╌╌╌╌╌╌╌╌╌╌╮     ╭╌╌╌╌╌╌╌╌┴╌╌╌╌╌╮   ╭╌╌╌╌╌╌┴╌╌╌╌╌╌╮
                  ┆     ObservableValue  ┆     ┆ObservableList┆   ┆ObservableSet┆
                  ┆ val value : V           ┆     ╰╌╌╌╌╌╌╌╌╌╌╌╌╌╌╯   ╰╌╌╌╌╌╌╌╌╌╌╌╌╌╯
                  ┆ addChangeListener()     ┆
                  ┆ removeChangeListener()  ┆
                  ┆                         ┆
                  ╰╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╯
                               △                                                          ╭╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╮
                               ├─────────────────────────────────────────┐                ┆InvalidationListener┆
                     ╭╌╌╌╌╌╌╌╌╌┴╌╌╌╌╌╌╌╌╌╌╮                   ┌──────────┴──────────┐     ┆  invalidated()     ┆
                     ┆   ReadOnlyProperty ┆                   │ ObservableValueBase │◇────┤                    ┆
                     ┆ bean : Any?        ┆                   │  listeners          │     ╰╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╯
                     ┆ beanName : String  ┆                   │  changeListeners    │     ╭╌╌╌╌╌╌╌╌╌╌╌╌╌╌╮
                     ┆                    ┆                   │                     │◇────┤ChangeListener┆
                     ╰╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╯                   └──────────┬──────────┘     ┆   changed()  ┆
                               △                                         │                ┆              ┆
            ┌──────────────────┴────┐                                    │                ╰╌╌╌╌╌╌╌╌╌╌╌╌╌╌╯
┏━━━━━━━━━━━┷━━━━━━━━━━━━━┓ ╭╌╌╌╌╌╌╌┴╌╌╌╌╌╌╌╌╮    ╭╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╮  │
┃ ReadOnlyPropertyWrapper ┃ ┆    Property    ┆    ┆ BidirectionalBind ┆  │
┃   listeners             ┃ ┆  var value : V ┆◀───┤  propertyA        ┆  │
┃   changeListeners       ┃ ┆                ┆◀───┤  propertyB        ┆  │
┃                         ┃ ┆                ┆    ┆  unbind()         ┆  │
┗━━━━━━━━━━━━━━━━━━━━━━━━━┛ ╰╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╯    ╰╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╯  │
                                     △                                   │
                                     │                                   │
                                     │                                   │
        ┌────────────────────────┬───┴───────────────────────────────────┴───┐
╭╌╌╌╌╌╌╌┴╌╌╌╌╌╌╌╌╌╌╮     ┌───────┴────────┐                      ┌───────────┴──────────┐
┆ StylableProperty ┆     │  PropertyBase  │                      │ LazyObservableValue  │
┆   kClass()       ┆     │                │                      │  invalidate()        │
┆   style()        ┆     │                │                      │  eval()              │
┆   revert()       ┆     └────────────────┘                      │  addDependant()      │
╰╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╯             △                               │  removeDependant()   │
        △ (Used by Themes)       │                               └──────────────────────┘
        │                        │                                           △
        │                        │                         ┌─────────────────┴────────────────────┐
        │               ┏━━━━━━━━┷━━━━━━━━┓       ┏━━━━━━━━┷━━━━━━┓ ┏━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━┷━━━━━━┓
        │               ┃  SimpleProperty ┃       ┃ UnaryFunction ┃ ┃ BinaryFunction ┃ ┃ TernaryFunction ┃
        │               ┃                 ┃       ┃  argA         ┃ ┃  argA          ┃ ┃  argA           ┃
        │               ┃                 ┃       ┃  lambda       ┃ ┃  argB          ┃ ┃  argB           ┃
        │               ┗━━━━━━━━━━━━━━━━━┛       ┗━━━━━━━━━━━━━━━┛ ┃  lambda        ┃ ┃  argC           ┃
        │                        △                                  ┗━━━━━━━━━━━━━━━━┛ ┃  lambda         ┃
        │     ┌──────────────────┘                                                     ┗━━━━━━━━━━━━━━━━━┛
┏━━━━━━━┷━━━━━┷━━━━━━━━┓
┃SimpleStylableProperty┃
┃                      ┃
┃                      ┃
┗━━━━━━━━━━━━━━━━━━━━━━┛

Created with Blokart

Inheritors

Properties

Link copied to clipboard
abstract val value: V

Functions

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open operator fun getValue(thisRef: Any, kProperty: KProperty<*>): V

Lets us declare a val using a for the value of this property, using this as a delegate. e.g.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard