james
08/05/2019, 1:16 AMandroid:text="@{viewModel.message(context::getString)}"
where my viewModel
class has a function like:
fun message(getStringFunc: (Int) -> String)
gildor
08/05/2019, 1:43 AMjames
08/05/2019, 1:56 AMgildor
08/05/2019, 2:00 AMjames
08/05/2019, 5:30 AMmessage
function in the viewModel whose parameter is the wrong type (the type is as above, and it's looking for fun message(object: Object)
)gildor
08/05/2019, 5:34 AMjulienquievreux
08/05/2019, 7:13 AMgildor
08/05/2019, 7:22 AMyou can, but the “context::getString” part won’t workIsn’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