https://kotlinlang.org logo
#koin-contributors
Title
# koin-contributors
Finally, I've figured out why factory called twice when trying to obtain instance that declared in root scope from a custom scope.
Copy code
private fun <T> findInOtherScope(
    clazz: KClass<*>,
    qualifier: Qualifier?,
    parameters: ParametersDefinition?
): T? {
    return _linkedScope.firstOrNull { scope ->
        scope.getOrNull<T>(
            clazz,
            qualifier,
            parameters
        ) != null
    }?.get(
        clazz,
        qualifier,
        parameters
    )
}
firstOrNull predicate lambda calling scope.getOrNull() and a factory called first time, then if it's not null factory called second time.
a

arnaud.giuliani

04/14/2020, 7:43 AM
Great, thanks @scraplesh