https://kotlinlang.org logo
#squarelibraries
Title
# squarelibraries
k

kevin.cianfarini

02/10/2023, 10:16 PM
The reason that Google recommends
ViewModel
for compose likely hinges on the interaction of the hilt library,
ViewModel
, and compose navigation. They're so closely intertwined that some use cases are nice to use with that. If you try to do anything out of the norm (see: assisted injection) you get nothing but pain
c

Colton Idle

02/13/2023, 4:24 AM
FWIW, I think assisted injection now that its built into dagger/hilt actually works well with all those libs
k

kevin.cianfarini

02/13/2023, 4:38 AM
Last I heard this issue hasn't been resolved yet. https://github.com/google/dagger/issues/2287
c

Colton Idle

02/13/2023, 1:31 PM
Oooh. I def just used it and it worked. lol. I wonder if I need to leave a comment similar to this one i just left last week 😂 https://github.com/google/dagger/issues/1908#issuecomment-1424328026
Okay, that thread actually has a tonnnn more convo going on in it. almost to the point where its hard to follow what is supported currently and what is not supported currently. dagger seems to have "assisted injection" though and the last time i used AI it was for a use case, not an AAC VM, so maybe that actually doesn't work. https://dagger.dev/dev-guide/assisted-injection.html
k

kevin.cianfarini

02/13/2023, 1:44 PM
@AssistedInject
does not work for classes annotated with
@HiltViewModel
currently and fails with a compiler error.
The thread is definitely difficult to follow. I want to rip hilt out of our codebase so bad.
c

Colton Idle

02/13/2023, 3:53 PM
Ah gotcha. Then yeah I misremembered our impl. We currently use saved state handle with compose nav in order to get the typical destination based args.
2 Views