zsperske
07/15/2020, 5:40 PMstreetsofboston
07/15/2020, 6:12 PMios
Swift/Obj-C code, or from the iosMain
shared code?zsperske
07/15/2020, 6:12 PMstreetsofboston
07/15/2020, 6:13 PMstreetsofboston
07/15/2020, 6:15 PMfun initKoin(….)
) and the initKoin
has parameter(s) defined as `interface`s.
When calling initKoin(…)
from Swift (these `interface`s are represented as protocols) provide implementations of these protocol(s) as input to the call to initKoin(…)
zsperske
07/15/2020, 6:17 PMzsperske
07/15/2020, 6:17 PMzsperske
07/15/2020, 6:17 PMfun init(eventDataSource: EventDataSource) {
koin = initKoin {
module {
single { eventDataSource }
}
}
}
streetsofboston
07/15/2020, 6:17 PMzsperske
07/15/2020, 6:17 PMzsperske
07/15/2020, 6:17 PMstreetsofboston
07/15/2020, 6:18 PMshared
module of your project. But if all else fails, do this passing of protocol-implementations when init-ing the Koin instance.streetsofboston
07/15/2020, 6:18 PMzsperske
07/15/2020, 6:19 PMiOSMain
code, I can pull those swift/obj-c classes into my kotlin as well right?streetsofboston
07/15/2020, 6:20 PMshared
module, then yes.streetsofboston
07/15/2020, 6:21 PMinterface
(protocol) and implementations of them over expect
and actual
. We reserve expect
and actual
for specific use-cases only.zsperske
07/15/2020, 6:22 PMexpect/actual
and interface
?streetsofboston
07/15/2020, 6:25 PMexpect/actual
for simple top-level functions, top-level vals, etc. Otherwise `interface`s.
However, if the interface
implementations require constant down-casting on the app
or ios
side of the code and there is truly only one implementation for each target (one for app
, one for ios
), then you may want to consider using expect/actual
again.streetsofboston
07/15/2020, 6:26 PMzsperske
07/15/2020, 6:30 PMrusshwolf
07/15/2020, 6:46 PMKClass
internally of anything in the dependency graph. If you want to add a Swift/Obj-C type to the Koin graph, it will fail. You can work around it by casting to Any
and using qualifiers, but it gets syntactically pretty ugly.russhwolf
07/15/2020, 6:48 PMzsperske
07/15/2020, 8:02 PMrusshwolf
07/15/2020, 8:34 PMNSUserDefaults
from Swift, but it’s messy to bind that directly to Koin rather than constructing AppleSettings
and passing that to Koin.zsperske
07/15/2020, 8:37 PMrusshwolf
07/15/2020, 8:57 PMzsperske
07/15/2020, 9:02 PM