Since Kotlin 1.1 added bound callable references, binding observables to UI actions can be simplified significantly, mainly using normal functions as actions instead of vals with the type Func1<Observable<T>, Subscription>.
Quick example:
interface MainView {
...
fun signInSuccess(success: Success)
...
}
class Presenter {
...
signInResult
.filter { it is Success }
.map { it as Success }
.bind(view::signInSuccess)
...
}
fun <T> Observable<T>.bind(action: (T) -> Unit): Subscription =
observeOn(AndroidSchedulers.mainThread()).subscribe(action)
Since Kotlin 1.1 added bound callable references, binding observables to UI actions can be simplified significantly, mainly using normal functions as actions instead of
val
s with the typeFunc1<Observable<T>, Subscription>
.Quick example:
What are your thoughts on this?