What is the preferred approach - pass `ViewModel`...
# compose
m
What is the preferred approach • pass
ViewModel
as a param to the composable • use
Koin
to inject
ViewModel
Can you point out pros & cons also because I don't see much of a difference
i
The latest video explains one approach in doing both - pass it in as a parameter, but include a default value for the ViewModel that pulls from Koin, Hilt, etc.:

https://www.youtube.com/watch?v=0z_dwBGQQWQ

👍🏽 1
👍 1
m
So in any case, we can provide the
ViewModel
to a Composable as a parameter or is there any alternative?
d
Passing as a param, defaulted to your DI of choice gets you the best of both worlds: DI + totally effortless override when you want to throw together a Unit Test etc. Is there any reason to find an alternative?
c
Thanks Ian, again a helping hand.