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

adalbert

02/28/2018, 8:03 PM
Hi! Is this possible to add own extension method to
RxView
from RxBinding ? (I got unresolved reference)
Copy code
fun RxView.throttledClick(v: View, s: () -> Any) {
        this.clicks(v).throttleFirst(1000, TimeUnit.MILLISECONDS).subscribe{s()}
    }
I tried to look deeper
Copy code
@CheckResult
inline fun View.clicks(): Observable<Unit> = RxView.clicks(this).map(VoidToUnit)
But I am still confused why I can't just add extension method. (I am still new to kotlin)
e

edwardwongtl

03/01/2018, 3:39 AM
RxView itself does not have instance, it just provide a brunch of static methods. Extension method is applied to the instance of the class and not the class itself.
👍 2
a

adalbert

03/01/2018, 5:28 PM
thanks!
2 Views