Okay-ish:
DependencyListDirectory.default.get(IsAuthenticatedUseCase.self)
That
get
is our function:
func get<T>(_ type: T.Type) -> T {
sharedDependencyList.get(objCObject: type) as! T
}
func get<T>(_ type: T.Type, qualifier: Qualifier?) -> T {
sharedDependencyList.get(objCObject: type, qualifier: qualifier) as! T
}
Which calls in the
Koin
instance:
private var sharedDependencyList: Koin!
And that
get
in Koin is our own extension defined in the
ios
sourceset in Kotlin, as to retrieve the Kotlin class:
// region Helper functions to retrieve a Koin dependency from Swift code.
fun Koin.get(objCObject: ObjCObject): Any {
return get(objCObject, null)
}
fun Koin.get(objCObject: ObjCObject, qualifier: Qualifier?): Any {
val kClazz = when (objCObject) {
is ObjCClass -> getOriginalKotlinClass(objCObject)!!
is ObjCProtocol -> getOriginalKotlinClass(objCObject)!!
else -> {
throw IllegalArgumentException("Koin.get objObject must be a class or a protocol")
}
}
return get(kClazz, qualifier, null)
}
// endregion.