RxPM
RxPM copied to clipboard
Type projection for Action
trafficstars
Hey guys.
I was trying to user single action as a common sink for multiple buttons:
Observable.just(1).bindTo(pm.someAction)
Observable.just(1.0).bindTo(pm.someAction)
where someAction is
val someAction = action<Number>()
And I've got the compile time error, which can be fixed by
infix fun <T> Observable<T>.bindTo(action: Action<in T>) { //type projection here
with(action.pm) {
[email protected](AndroidSchedulers.mainThread())
.subscribe(action.consumer)
.untilUnbind()
}
}
Have you done it on purpose, so any `action` has strict type parameter?
Yep, thanks. Will check it.
On the other hand there might be some type issues with this approach. Maybe its better to have actions zipped together in pm, than one typed actions
@lectricas What issues do you mean?