diff --git a/demo/motors/src/main/kotlin/ru/mipt/npm/devices/pimotionmaster/fxDeviceProperties.kt b/demo/motors/src/main/kotlin/ru/mipt/npm/devices/pimotionmaster/fxDeviceProperties.kt index e8b4e68..93f9f7c 100644 --- a/demo/motors/src/main/kotlin/ru/mipt/npm/devices/pimotionmaster/fxDeviceProperties.kt +++ b/demo/motors/src/main/kotlin/ru/mipt/npm/devices/pimotionmaster/fxDeviceProperties.kt @@ -12,8 +12,8 @@ import tornadofx.* /** * Bind a FX property to a device property with a given [spec] */ -fun Device.fxProperty( - spec: DevicePropertySpec +fun D.fxProperty( + spec: DevicePropertySpec, ): ReadOnlyProperty = object : ObjectPropertyBase() { override fun getBean(): Any = this override fun getName(): String = spec.name @@ -21,16 +21,12 @@ fun Device.fxProperty( init { //Read incoming changes onPropertyChange(spec) { - if (it != null) { - runLater { - try { - set(it) - } catch (ex: Throwable) { - logger.info { "Failed to set property $name to $it" } - } + runLater { + try { + set(it) + } catch (ex: Throwable) { + logger.info { "Failed to set property $name to $it" } } - } else { - invalidated() } } }