Fix property listener

This commit is contained in:
Alexander Nozik 2023-05-24 09:56:02 +03:00
parent 2a966d8cb3
commit b7be570271

View File

@ -12,8 +12,8 @@ import tornadofx.*
/**
* Bind a FX property to a device property with a given [spec]
*/
fun <D : Device, T : Any> Device.fxProperty(
spec: DevicePropertySpec<D, T>
fun <D : Device, T : Any> D.fxProperty(
spec: DevicePropertySpec<D, T>,
): ReadOnlyProperty<T> = object : ObjectPropertyBase<T>() {
override fun getBean(): Any = this
override fun getName(): String = spec.name
@ -21,7 +21,6 @@ fun <D : Device, T : Any> Device.fxProperty(
init {
//Read incoming changes
onPropertyChange(spec) {
if (it != null) {
runLater {
try {
set(it)
@ -29,9 +28,6 @@ fun <D : Device, T : Any> Device.fxProperty(
logger.info { "Failed to set property $name to $it" }
}
}
} else {
invalidated()
}
}
}
}