privatefunsync(source: Property<T>, newValue: T?) { if (isSyncing || newValue == null) return isSyncing = true try { for ((prop, _) in propertyMap) { if (prop !== source) updateIfChanged(prop, newValue) } } finally { isSyncing = false } }
privatefunupdateIfChanged(target: Property<T>, newValue: T) { val current = target.value val shouldUpdate = when { newValue is Number && current is Number -> abs(newValue.toDouble() - current.toDouble()) > epsilon // 浮点走容差 else -> newValue != current // 其他走相等 } if (shouldUpdate) target.value = newValue } }