commonMain.com.makeevrserg.mobile.di_container.Factory.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of service-locator-jvm Show documentation
Show all versions of service-locator-jvm Show documentation
KMM library with frequently used code
package com.makeevrserg.mobile.di_container
import kotlin.reflect.KProperty
/**
* IFactory is need for re-creating object, for example, viewModels
*/
abstract class Factory : Dependency {
protected abstract fun initializer(): T
override val value: T
get() = initializer()
}
fun factory(initializer: () -> T) = object : Factory() {
override fun initializer(): T = initializer()
}
inline operator fun Factory.getValue(t: K?, property: KProperty<*>): T = value
© 2015 - 2025 Weber Informatics LLC | Privacy Policy