https://kotlinlang.org logo
#android
Title
# android
x

xingstarx

01/09/2018, 4:05 AM
Hi everyone, I want to implements Observable in kotlin ,use this code ,
Copy code
kotlin fun <T> KProperty0<T>.addObserver(observer: (T) -> Unit) {
    (apply { isAccessible = true }.getDelegate() as MutableProperty<T>).addObserver(observer)
}
but I found Some mistakes appeared online, like this
Copy code
kotlin.reflect.full.IllegalPropertyDelegateAccessException: Cannot obtain the delegate of a non-accessible property. Use "isAccessible = true" to make the property accessible
can everyone help me