All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.makeevrserg.mobile.di_container.Factory.kt Maven / Gradle / Ivy

There is a newer version: 2.7.3
Show newest version
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