https://kotlinlang.org logo
#stdlib
Title
# stdlib
u

uliluckas

09/24/2019, 9:09 PM
Hi there, is there a reason not to have a type parameter for the delegate on a
KProperty
? if there was, one could write extension functions, depending on the delegate type. I.e.
Copy code
fun KProperty<*, BehaviorRelayDelegate>.subscribe(O: Observer)
and use it like
Copy code
val v : Int by BehaviorRelayDelegate(0)
::v.subscribe { Log("Value changed to $it" }
v = 2
val v1 = v
i

ilya.gorbunov

09/24/2019, 10:25 PM
Property delegation is considered an implementation detail of a property, thus a statically reflected
KProperty
cannot expose that detail, i.e. the delegate type.
2 Views