loke
11/02/2024, 9:16 AMObjectPropertyBase
, create a function called fooProperty
that returns an instance of this class, and then create getFoo()
and setFoo()
methods that delegate to this property. I've been trying to make a nicer way to achieve this by using Kotlin delegates, but my result is not much shorter than the Java style. Surely there must be some neat way to achieve this? Is this something someone has already done?Daniel Pitts
11/02/2024, 1:40 PMSimpleObjectProperty
instead?ephemient
11/02/2024, 2:16 PMclass MyBean {
var foo: T by SimpleObjectProperty(this, "foo")
}
you just need some functions in scope like
operator fun <T> ReadableProperty<T>.getValue(thisRef: Any?, property: KProperty<*>): T =
getValue()
operator fun <T> WritableProperty<T>.setValue(thisRef: Any?, property: KProperty<*>, value: T) {
setValue(value)
}
loke
11/02/2024, 3:41 PMephemient
11/02/2024, 3:53 PMloke
11/02/2024, 3:54 PM