AssistedInject ViewModel helpers #179
steurt
started this conversation in
Discuss noty-android (Android development)
Replies: 1 comment
-
@steurt this structure really looks good and clean too. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I came across the blog post Providing AssistedInject supported ViewModel for Composable using Hilt through Android Weekly. Coincidentally I was just about to see how I could make AssistedInject work alongside Hilt and Compose. The post therefore was very helpful!
I applied the described setup and extended on it a little by adding some helpers to make the setup a bit more generic with a bit less boilerplate code.
I added the
AssistedViewModel.kt
file:With these helpers in this case the
fun noteDetailViewModel
can be removed. The helpers can now simply be used as follows:What do you think of this setup?
Beta Was this translation helpful? Give feedback.
All reactions