Oscar Sequeiros
03/22/2020, 9:14 PMLeland Richardson [G]
03/22/2020, 11:23 PMOscar Sequeiros
03/22/2020, 11:55 PMprivate fun bind() {
disposables.add(viewModel.states().subscribe(this::render))
viewModel.processIntents(intents())
}
private fun render(state: ItemsViewState) {
}
I want to know how I could call a composable function into render, I know that the composable functions can only be called from another composable or setContent function.Leland Richardson [G]
03/23/2020, 1:49 AMstate { … }
composable. Then when you subscribe to vviewModel.states()
you can update that value which will cause a recomposition.
for instance, you could do something like this:
@Composable fun ComposeState(state: ItemsViewState) { ... }
setContent {
val x = state<ItemsViewState?> { null }
onActive { viewModel.states().subscribe { x.value = it } }
x.value?.let { ComposeState(it) }
}
Something like that. There are lots of different ways to do this, some better than others depending on the context, but hopefully this can get you started?Oscar Sequeiros
03/23/2020, 3:21 AM