have you tried? it’s more about method reference implementation of bindings
j
james
08/05/2019, 1:56 AM
yeah I tried, the data binding code gen fails
g
gildor
08/05/2019, 2:00 AM
and what is error message?
j
james
08/05/2019, 5:30 AM
when it's trying to generate, it's looking for a
message
function in the viewModel whose parameter is the wrong type (the type is as above, and it's looking for
fun message(object: Object)
)
g
gildor
08/05/2019, 5:34 AM
looks as some problem of databindings, I would report to Android issue tracker
j
julienquievreux
08/05/2019, 7:13 AM
you can, but the "context::getString" part won't work. Context shouldn't be pass. replace it with something like viewModel.message(messageRes) where messeRes is a variable bind in your xml
g
gildor
08/05/2019, 7:22 AM
you can, but the “context::getString” part won’t work
Isn’t this the whole point of this question. To pass some abstract function instead of exposing context.
I’m not sure that it’s good enough solution, usually we provide own abstraction for resources to ViewModel, but imo using function instead of exposing context is better
gildor
08/05/2019, 7:22 AM
But yeah, use resource is also good, but not always possible