dasralph
02/18/2016, 1:32 PMfun <T> Observable<T>.subscribeOrLogError(onNext: Action1<T>): Subscription {
return subscribe(object : Subscriber<T>() {
override fun onCompleted() {
// do nothing
}
override fun onError(e: Throwable) {
Timber.e(e, "")
}
override fun onNext(args: T) {
onNext.call(args)
}
})
}
When I use it I have to write:
val subject = PublishSubject<Boolean>()
subject.subscribeOrLogError(Action1<Boolean> { it -> Timber.i("value: " + it) })
Is there a way that I don’t need to write Action1<Boolean>
in the subject.subscribeOrLogError call?