# compose

Manuel Lorenzo

10/06/2020, 7:01 AM
Hi everybody! I've been trying to wrap my head around compose and the way of creating UI in a declarative way by doing some of the code labs and trying to adapt a small app I have that makes a couple of API requests to an external API by using flow and Retrofit. Nevertheless I'm having some troubles observing the data in the ViewModel and just showing the results in a recycler view in the fragment. I haven't run into any example that does similar things, not even in the compose samples. Does anybody know any tutorial or repo that I can take a look at? Thanks a lot in advance!


10/06/2020, 7:05 AM
search for
in the compose-samples. you don’t need recyclerview or any android view for compose
☝️ 1

Colton Idle

10/06/2020, 12:30 PM
I'm new to compose too (I haven't built anything), but from what I've picked up here, you'll want a LazyColumn and then just funnel in an observable data holder into your root composable and just iterate over the list you passed in. Everything that's using retrofit and retrieving the data in general doesn't really change, since it's really only the UI layer that needs to be updated. In terms of observables types, I think theres a possibility to use Rx, Flow, LiveData, or compose (I think) comes with a State observable data holder that you can use (I forget the exact name).


10/06/2020, 12:35 PM
if you want a horizontal list. And check out the State codelab for integration with view model.

Vinay Gaba

10/06/2020, 3:51 PM
For converting llivedata to a compose specific format, you’d use something like this - There are similar extensions available for coroutines, rxjava, etc