Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type projection for Action #50

Open
lectricas opened this issue Nov 6, 2019 · 3 comments
Open

Type projection for Action #50

lectricas opened this issue Nov 6, 2019 · 3 comments

Comments

@lectricas
Copy link

lectricas commented Nov 6, 2019

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?
@Jeevuz
Copy link
Collaborator

Jeevuz commented Nov 13, 2019

Yep, thanks. Will check it.

@lectricas
Copy link
Author

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

@Jeevuz
Copy link
Collaborator

Jeevuz commented Nov 14, 2019

@lectricas What issues do you mean?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants