https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
s

Simon Buechner

09/27/2023, 9:45 PM
Hi guys, did anyone of you know a good guide setting koin up to only be used in the shared code and not using it to inject directly to the Android and iOS Apps? Is this even a good approach? I cant wrap my head around the concept, but didnt find some good guide/tutorial/sample code. im sorry if this is a little dumb question.
j

Jacob Ras

09/27/2023, 10:08 PM
Here's the approach I'm using: https://medium.com/better-programming/multiplatform-dependency-injection-making-koin-dagger-hilt-and-swinject-work-together-on-android-e17b98bd8f7b It keeps Koin within the shared code, unless my target also uses Koin.
s

Simon Buechner

09/27/2023, 10:39 PM
so in this approach i would create some modules. then i would call startKoin in the init block of my facade class or EntryPoint. There i would add all modules/classes i created. lets assume i have 4 modules: Session Bluetooth Logging DataConversion DataConversion needs Bluetooth Session needs DataConversion Session needs Bluetooth All need Logging I start bleScanning in my Facade where i load the modules with startKoin. <facade>.bleScanning calls session.scan session.scan calls bluetooth.scan session gets a flow from bluetooth facade gets the same flow from session Every function call is logged by logging Would this work with the koin approach or am i assuming things the wrong way? Thanks for your fast help with the guide @Jacob Ras
2 Views