You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I need to declare some instances at scope creation for which I don't know its concrete type until runtime. If I use the declare function as is now, those instances get stored with its base type and then resolution does not work.
Describe the solution you'd like
I'd like for Scope.declare function to be modified so the instance primary type can be specified independently, like this:
inline fun <reified T> declare(
instance: T,
qualifier: Qualifier? = null,
secondaryTypes: List<KClass<*>> = emptyList(),
allowOverride: Boolean = true,
primaryType: KClass<T> = T:class //requesting this parameter be added
)
Then InstanceRegistry.declareScopedInstance and _createDefinition in BeanDefinition.kt would need to be modified so that they take the primary type as a parameter, but they would not need to be declared as inline.
Describe alternatives you've considered
Right now I'm passing a generic supertype to the classes that need an instance of the problematic class and then I cast it, but it's ugly and dangerous.
Target Koin project
Core
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
I need to declare some instances at scope creation for which I don't know its concrete type until runtime. If I use the
declare
function as is now, those instances get stored with its base type and then resolution does not work.Describe the solution you'd like
I'd like for
Scope.declare
function to be modified so the instance primary type can be specified independently, like this:Then
InstanceRegistry.declareScopedInstance
and_createDefinition
inBeanDefinition.kt
would need to be modified so that they take the primary type as a parameter, but they would not need to be declared asinline
.Describe alternatives you've considered
Right now I'm passing a generic supertype to the classes that need an instance of the problematic class and then I cast it, but it's ugly and dangerous.
Target Koin project
Core
The text was updated successfully, but these errors were encountered: