Currently we are using RxView to handle throttle c...
# android
r
Currently we are using RxView to handle throttle clicks inside app and we have utility functions to subscribe on click listeners, we never unsubscribe from them. Is there an easy way to do so? or similar?
Copy code
fun throttledClick(
        targetView: View,
        completionMethod: () -> Unit,
        throttleWindow: Long = DOUBLE_CLICK_THROTTLE_WINDOW
    ) {
        RxView.clicks(targetView)
            .throttleFirst(throttleWindow, MILLISECONDS)
            .subscribe {
                completionMethod.invoke()
            }
    }
s
Couple ways of doing it imo, You could have a base class with disposables val and that gets disposed in appropriate lifecycle OR Create lifecycle aware component that does the same as above
r
Thanks a lot @Stanley Gomes