mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-12-23 09:07:14 +00:00
commit
a067cb0c0f
@ -1,5 +1,10 @@
|
||||
# Changelog
|
||||
|
||||
## 0.18.4
|
||||
|
||||
* `Koin`:
|
||||
* New extension `lazyInject`
|
||||
|
||||
## 0.18.3
|
||||
|
||||
* `Versions`:
|
||||
|
@ -14,5 +14,5 @@ crypto_js_version=4.1.1
|
||||
# Project data
|
||||
|
||||
group=dev.inmo
|
||||
version=0.18.3
|
||||
android_code_version=194
|
||||
version=0.18.4
|
||||
android_code_version=195
|
||||
|
27
koin/src/jvmMain/kotlin/LazyInject.kt
Normal file
27
koin/src/jvmMain/kotlin/LazyInject.kt
Normal file
@ -0,0 +1,27 @@
|
||||
package dev.inmo.micro_utils.koin
|
||||
|
||||
import org.koin.core.parameter.ParametersDefinition
|
||||
import org.koin.core.qualifier.Qualifier
|
||||
import org.koin.java.KoinJavaComponent
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
fun <T> lazyInject(
|
||||
kClassFactory: () -> KClass<*>,
|
||||
qualifier: Qualifier? = null,
|
||||
parameters: ParametersDefinition? = null
|
||||
): Lazy<T> {
|
||||
return lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
|
||||
KoinJavaComponent.get(kClassFactory().java, qualifier, parameters)
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> lazyInject(
|
||||
kClass: KClass<*>,
|
||||
qualifier: Qualifier? = null,
|
||||
parameters: ParametersDefinition? = null
|
||||
): Lazy<T> = lazyInject({ kClass }, qualifier, parameters)
|
||||
|
||||
inline fun <reified T> lazyInject(
|
||||
qualifier: Qualifier? = null,
|
||||
noinline parameters: ParametersDefinition? = null
|
||||
): Lazy<T> = lazyInject(T::class, qualifier, parameters)
|
Loading…
Reference in New Issue
Block a user