Has someone integrated Dagger in such a way where ...
# compose
u
Has someone integrated Dagger in such a way where dagger provides Screen composables? if so, how, ifi ts just
() -> @Composable Unit
lamdas? Qualifieres everywhere? Or maybe some typesafe object based Screen? is that a bad idea? (since it doesnt really compose if needed, same way fragments sort of did)
b
I’m not sure how this would work, or why you would need it? The purpose of dagger (or any DI framework) is to create and inject instances of objects in a class, rather than the class having to create them itself. It exists to solve a problem where a class A that needs to use an instance of another class B needs to know the details about how to create an instance of B (which could mean creating instances of several other objects as well). But composables are not objects or classes, but just simple functions. There’s no instance to create, and thus there’s no problem to solve.
u
Well Im mostly talking about instantiation of the viewmodels passed in, someone needs to construct them
i
Hilt has integrations with Compose to provide ViewModels, including providing them at the screen by screen level (via integration with Navigation Compose): https://developer.android.com/jetpack/compose/libraries#hilt