Just to clarify, I understand DI well enough, but I wouldn’t know how to provide, say, the equivalent of a Dagger module that injects library objects with platform implementations. I wonder if I’m overthinking it, or if anyone could point me to an example of a good way to achieve this goal.
d
Dico
06/26/2019, 9:23 AM
Perhaps you can use ServiceLoader. It's only for jvm though
k
Kris Wong
06/26/2019, 12:57 PM
why not just inject a concrete implementation of an interface directly as a constructor parameter?
s/inject/pass/
dagger is great but it's not mandatory 🙂
d
Dico
06/26/2019, 1:08 PM
Yeah I'm also not a fan of depending on libraries for DI. I think kotlin makes it pretty easy without.
k
kieran
06/27/2019, 12:46 AM
Thanks for the suggestions guys. I didn’t mean to suggest I wanted to use Dagger in MPP, just that I wondered if anything similar (either a library or a good example of the DI pattern) was available for common code.
k
Kris Wong
06/27/2019, 1:10 PM
i know there are kotlin libraries for DI, however i don't know if they're compatible with native/multiplatform