Hi, Wich is the best way to use Hilt with Maverick...
# android
y
Hi, Wich is the best way to use Hilt with Mavericks viewmodel ?
đŸ˜¶ 3
a
I found setting up hilt with Mavericks to be a right pain. Firstly take a look at the sample, https://github.com/airbnb/mavericks/tree/master/hellohilt. You need to copy the following files from it into your project: AssistedViewModelFactory.kt MavericksViewModelScoped.kt ViewModelKey.kt ViewModelsModule.kt hiltMavericksViewModelFactory.kt Your viewmodel then needs assistedinject and an assistedfactory added before “by fragmentViewModel()” will work in your fragment. Personally I found this all far too much, both from a copy and paste point of view and a boilerplate code point of view. If you’re only just starting to look at MVI check out https://github.com/orbit-mvi/orbit-mvi, the syntax is easier to read, doesn’t require implementing interfaces all over the place and above all you can use it within a standard jetpack viewmodel so @HiltViewModel simply works, no complicated or messy setup. The feature set isn’t identical to Mavericks so you’ll have to judge for yourself if it meets your needs.
132 Views