https://kotlinlang.org logo
#android
Title
# android
l

lawlorslaw

06/26/2020, 12:30 AM
Hey are there any recommendations how i can simplify the creation of a viewmodel across all my features. Right now I have it set up like this. I tried briefly looking into Kotlin delegates but I haven’t come across an example that didnt seem overly complicated. I would like to continue to use Dagger and not switch to a different dependency injection framework.
i

Isaac

06/26/2020, 8:18 AM
You could look into using Hilt, it'll surely give you a more elegant way to create your ViewModels
m

Matiasdelbel

06/26/2020, 1:55 PM
Yes, you could use hilt... Also, if you want to continue using dagger, you can use android-dagger... finally, androidX provides you some extension function to create a view models
val viewModel by viewModels {  }
11 Views