https://kotlinlang.org logo
k

Kshitij Patil

10/28/2020, 5:21 AM
Has anyone used Hilt with Compose? I'm willing to inject different instances of same type based on some condition. Also, is it possible to inject dependencies directly into a composable? I think 'Ambient' is another way of maintaining dependencies.
j

Jeremy

10/28/2020, 2:05 PM
I'm using it at the activity/application level. compose functions you can just pass in dependencies or functions like
Copy code
@Composable
fun MyCoolWidget(doSomething: (String) -> Unit) {}
call it via
MyCoolWidget(myViewModel::doSomething)
3 Views