Updated koin

This commit is contained in:
Viktor De Pasquale 2019-05-24 12:28:57 +02:00
parent f0a734fdab
commit 77470c7cfa
2 changed files with 3 additions and 6 deletions

View File

@ -74,7 +74,7 @@ dependencies {
implementation "com.github.topjohnwu.libsu:core:${libsuVersion}" implementation "com.github.topjohnwu.libsu:core:${libsuVersion}"
implementation "com.github.topjohnwu.libsu:io:${libsuVersion}" implementation "com.github.topjohnwu.libsu:io:${libsuVersion}"
def koin = "2.0.0-rc-2" def koin = "2.0.0-GA6"
implementation "org.koin:koin-core:${koin}" implementation "org.koin:koin-core:${koin}"
implementation "org.koin:koin-android:${koin}" implementation "org.koin:koin-android:${koin}"
implementation "org.koin:koin-androidx-viewmodel:${koin}" implementation "org.koin:koin-androidx-viewmodel:${koin}"

View File

@ -3,18 +3,15 @@ package com.topjohnwu.magisk.utils
import org.koin.core.context.GlobalContext import org.koin.core.context.GlobalContext
import org.koin.core.parameter.ParametersDefinition import org.koin.core.parameter.ParametersDefinition
import org.koin.core.qualifier.Qualifier import org.koin.core.qualifier.Qualifier
import org.koin.core.scope.Scope
fun getKoin() = GlobalContext.get().koin fun getKoin() = GlobalContext.get().koin
inline fun <reified T : Any> inject( inline fun <reified T : Any> inject(
qualifier: Qualifier? = null, qualifier: Qualifier? = null,
scope: Scope? = null,
noinline parameters: ParametersDefinition? = null noinline parameters: ParametersDefinition? = null
) = lazy { get<T>(qualifier, scope, parameters) } ) = lazy { get<T>(qualifier, parameters) }
inline fun <reified T : Any> get( inline fun <reified T : Any> get(
qualifier: Qualifier? = null, qualifier: Qualifier? = null,
scope: Scope? = null,
noinline parameters: ParametersDefinition? = null noinline parameters: ParametersDefinition? = null
): T = getKoin().get(qualifier, scope, parameters) ): T = getKoin().get(qualifier, parameters)