Created
June 25, 2022 14:20
-
-
Save alibahaaa/ec626c6f06d181341e82e19a90a9449b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.koin.core.Koin | |
import org.koin.core.context.startKoin | |
import org.koin.core.parameter.parametersOf | |
import org.koin.dsl.KoinAppDeclaration | |
import org.koin.dsl.module | |
import kotlin.reflect.KClass | |
fun initKoin(appDeclaration: KoinAppDeclaration = {}) = startKoin { | |
appDeclaration() | |
modules(commonModule, platformModule()) | |
} | |
fun initKoin() = initKoin {} | |
val commonModule = module { | |
single { createJson() } | |
single { createHttpClient(get()) } | |
single<RemoteDatasource> { RemoteDatasourceImpl(get()) } | |
single<Repository> { RepositoryImpl(get()) } | |
single { GetOrigamiUseCase(get()) } | |
} | |
fun <T> Koin.getDependency(clazz: KClass<*>): T { | |
return get(clazz, null) { parametersOf(clazz.simpleName) } as T | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment