add content
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package dev.inmo.postssystem.features.common.common
|
||||
|
||||
import com.benasher44.uuid.uuid4
|
||||
import org.koin.core.definition.Definition
|
||||
import org.koin.core.instance.InstanceFactory
|
||||
import org.koin.core.module.Module
|
||||
import org.koin.core.qualifier.StringQualifier
|
||||
|
||||
/**
|
||||
* Will be useful in case you need to declare some singles with one type several types, but need to separate them and do
|
||||
* not care about how :)
|
||||
*/
|
||||
inline fun <reified T : Any> Module.singleWithRandomQualifier(
|
||||
createdAtStart: Boolean = false,
|
||||
noinline definition: Definition<T>
|
||||
) = single(uuid4().toString(), createdAtStart, definition)
|
@@ -0,0 +1,11 @@
|
||||
package dev.inmo.postssystem.features.common.common
|
||||
|
||||
import org.koin.core.definition.Definition
|
||||
import org.koin.core.module.Module
|
||||
import org.koin.core.qualifier.StringQualifier
|
||||
|
||||
inline fun <reified T : Any> Module.single(
|
||||
qualifier: String,
|
||||
createdAtStart: Boolean = false,
|
||||
noinline definition: Definition<T>
|
||||
) = single(StringQualifier(qualifier), createdAtStart, definition)
|
@@ -0,0 +1,14 @@
|
||||
package dev.inmo.postssystem.features.common.common
|
||||
|
||||
import kotlinx.serialization.modules.SerializersModuleBuilder
|
||||
|
||||
class SerializersModuleConfigurator(
|
||||
private val elements: List<Element>
|
||||
) {
|
||||
fun interface Element {
|
||||
operator fun SerializersModuleBuilder.invoke()
|
||||
}
|
||||
operator fun SerializersModuleBuilder.invoke() {
|
||||
elements.forEach { it.apply { invoke() } }
|
||||
}
|
||||
}
|
@@ -11,6 +11,6 @@ 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())
|
||||
): Pair<Module, InstanceFactory<T>> {
|
||||
return single(qualifier, createdAtStart, definition)
|
||||
}
|
||||
|
Reference in New Issue
Block a user