https://kotlinlang.org logo
#compose
Title
# compose
d

David Mcrae Jr

07/24/2020, 5:58 PM
Anyone have a good example showing a Data Class -> ViewModel -> Composable View with a FilledTextField (or any text field for that matter)? Most example projects don’t show data input…. Thanks in advance
b

Ben

07/24/2020, 8:26 PM
FWIW, i've been experimenting with it as well. https://github.com/bensadiku/DCFAndroid But i'd also look into JetNews the sample app.
👍 1
j

Jorge Castillo

07/26/2020, 8:27 AM
I'm curious and I beleive this is a discussion we've had many times. Always good to recap anyways. What's your opinion on mixing aac viewmodels and Compose? Per that repo I can see how you are using compose at an activity level, more like only for the UI side of things, so we could say lifecycle matches for the activity and your compose hierarchy under this scenario. But what would you do for something like tabs + screens for example? I've seen people staying with fragments, and keep compose only for the more strict UI stuff in there like you're doing, so they can keep viewmodels and livedata. Then I've seen other people moving on to declarative UI architectures that you can find in other platforms like React or Flutter, i.e: redux, MVI, unidirectional data flow etc, so they remove fragments, add a router component at the root activity that renders current screen based on a state and moves out from any acc stuff like viewmodel and livedata, since lifecycle of the screen doesn't really match anymore with the fragment / activity one. Instead of LiveData you got State, which is pretty much the compose solution for reactive UI that's efficient on recomposition.