aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/data/DataComponent.kt
blob: 605e1e2e6f76bad1d2338bca3c4d8f6c07edec63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package pl.treksoft.kvision.data

import kotlin.properties.ObservableProperty
import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty

open class DataComponent {
    var container: DataUpdatable? = null

    fun <T> obs(initialValue: T): ReadWriteProperty<Any?, T> = object : ObservableProperty<T>(initialValue) {
        override fun afterChange(property: KProperty<*>, oldValue: T, newValue: T) {
            container?.update()
        }
    }
}