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

Bryan Lee

12/13/2019, 6:48 PM
Maybe a silly question - Is there still a use for Live Data, Data Binding & View Models if using Compose? From my understanding, Compose takes care of observing data with @Model, persisting state across config changes, and there's no more layout for databinding.
p

Pablichjenkov

12/13/2019, 7:51 PM
If there is use for them, I don't see it. There is still a possible usage, if Google recommends it 😁
s

streetsofboston

12/13/2019, 8:19 PM
I asked the same question to Ian Lake at the Android Dev Summit this year. Talking to him I understood that LiveData and the other types of components will remain alive and kicking for a while. JetPack Compose is still a while out and I’m not sure Compose will even entirely replace the other ways of UI rendering.
👍 2
l

Leland Richardson [G]

12/13/2019, 8:27 PM
there’s possibly different answers for all of these, though we are still figuring out what we want to recommend in many cases. LiveData vs. Model: Model was built for a different use case than LiveData, though their usage overlaps quite a bit. Model was explicitly made to be used in concurrent contexts, even though the observability is the main thing that gets talked about. Model is easy to use with compose, but not yet easy to use outside of compose. we have some thinking to do in terms of whether or not we think Model usage outside of compose is something we want to recommend or not. Data Binding: In a simplistic sense, Data Binding is bringing logic to XML, and compose is bringing XML to logic, but both have the same goal. IMO taking data binding to its conclusion means building a full-fledged programming language inside of xml which i don’t think is a good idea (building programming languages is hard). I therefore don’t see a real future for data binding in a world where compose is an option (and production ready) View Models: I think there will still be use cases where viewmodel’s characteristics are useful and the right tool for the job, but i think right now there are things that are stuffed into viewmodels that probably shouldn’t be, and i think compose will end up teasing a lot of that out. time will tell though, i’m not as sure about this one and i’m probably not the right person to ask.
👍 7
s

streetsofboston

12/13/2019, 8:43 PM
I could still see a role for ViewModels or some other similar component that ties use-cases/business-logic to UI data fetching and UI actions, the bridge between business logic and UI. But yes, Compose may drain much of the current ViewModel’s functionality. 🙂
👍 2
r

Roar Gronmo

12/14/2019, 8:04 AM
@Leland Richardson [G] I hope it doesn't end in a situation where we need to mix those two... ...and we may end in a situation where we have two very different approches and camps in the community (android dev kotlin community) how to solve and develope android apps. Historicly, its like C vs C++, may look alike, but sooo different...
👍 1