Adam Brown
12/01/2021, 8:41 PMwbertan
12/01/2021, 8:52 PMAdam Brown
12/01/2021, 8:52 PMwbertan
12/01/2021, 8:56 PMDependencyListDirectory.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.
Adam Brown
12/01/2021, 8:57 PMAdam Brown
12/01/2021, 8:59 PMDependencyListDirectory
is a global you set some where to Koin's instance?wbertan
12/01/2021, 9:07 PMstartKoin
, which returns the KoinApplication
and then we store the koinApplication.koin
Adam Brown
12/01/2021, 9:08 PMwbertan
12/01/2021, 9:10 PMAdam Brown
12/01/2021, 9:11 PM