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

Arpit Shukla

02/05/2022, 3:10 PM
I have seen some discussions around avoiding architecture component view models in pure compose apps because these ViewModels only work in Android. Does that also mean I should avoid Hilt as well? If yes, what is the recommended way of dependency injection in such apps?
y

yschimke

02/05/2022, 3:22 PM
A personal opinion, but it seems awkard to ignore the very real lifecycle of ViewModel, Activities, Application. Hilt nicely models this with ViewModelScope, ActivityRetainedScope and so on. Be unfortunate to not be able to se this.
l

Landry Norris

02/05/2022, 7:52 PM
It likely depends on if your app is Android-only or if you plan on making it cross platform. If the app will be Android only for the foreseeable future, I would take advantage of the integration between Android libraries. If there's any chance of using KMM in the future, there are plenty of good options like decompose or moko-mvvm that also have good support for SwiftUI for architecture and DI libraries like Koin or Kodein.
k

K Merle

02/06/2022, 4:22 AM
If you use local or remote data in your app inside it's kind of hard to ignore it. You could ignore it tho, let us know about the results. 🙂
a

Arpit Shukla

02/06/2022, 4:34 AM
I wasn't really going to try this out 😅. I am building android-only apps and love the jetpack libraries, so going to stick with those. I was just wondering if there are some good samples/guidance out there implementing these recommendations.
k

K Merle

02/06/2022, 5:17 AM
I feel like this is how iOS looks.