package dev.inmo.postssystem.features.common.common

import org.koin.core.definition.Definition
import org.koin.core.instance.InstanceFactory
import org.koin.core.module.Module
import org.koin.core.qualifier.Qualifier
import org.koin.dsl.binds
import kotlin.reflect.full.allSuperclasses

inline fun <reified T : Any> Module.singleWithBinds(
    qualifier: Qualifier? = null,
    createdAtStart: Boolean = false,
    noinline definition: Definition<T>
): Pair<Module, InstanceFactory<*>> {
    return single(qualifier, createdAtStart, definition) binds (T::class.allSuperclasses.toTypedArray())
}
