ianbrandt
03/01/2020, 7:34 PMdeclare { }
DSL from Koin Test documented here: https://doc.insert-koin.io/#/koin-test/testing?id=declaring-a-component-on-the-fly
Here are the project sources: https://github.com/sdkotlin/sd-kotlin-talks/blob/16f05dfb7292dcfa87e5df1c5d92b06c66cadba1/di-with-koin/src/it/kotlin/org/sdkotlin/koin/it/hello/HelloModuleIT.kt#L81
I tried single
, and factory
as in the docs, but both result in a:
Unresolved reference. None of the following candidates is applicable because of receiver type mismatch...I thought maybe it could be an issue with the fact that I was using an inline class (experimental) as the component type, but it fails to compile with a simple String type as well:
declare { single { "testing" } }
.
Am I doing something wrong here, or should I file a GitHub issue? Koin and Koin Test 2.1.1.arnaud.giuliani
03/03/2020, 5:44 PMarnaud.giuliani
03/03/2020, 5:44 PM/**
* Declare a component definition from the given instance
* This result of declaring a single definition of type T, returning the given instance
*
* @param instance The instance you're declaring.
* @param qualifier Qualifier for this declaration
* @param secondaryTypes List of secondary bound types
* @param override Allows to override a previous declaration of the same type (default to false).
*/
fun <T : Any> declare(
instance: T,
qualifier: Qualifier? = null,
secondaryTypes: List<KClass<*>>? = null,
override: Boolean = false
) {
_scopeRegistry.rootScope.declare(instance, qualifier, secondaryTypes, override)
}
arnaud.giuliani
03/03/2020, 5:45 PMdeclare
declare directly an instance into Koinianbrandt
03/03/2020, 5:49 PM