Hi! Do you know the reason? Or I missed something?...
# kotlin-inject
k
Hi! Do you know the reason? Or I missed something? https://github.com/evant/kotlin-inject/issues/464
e
Provider functions need to be annotated with
@Provides
and can't be abstract
k
I know. I need a way to get some instance from the component. And I want to configure instance's scope right in the component
So, I need an abstract function because what DI framework's sense is if I need to construct classes manually 🙂
e
Change it to an
abstract val
. Then you don't need the
@Provides
, but you might still need the scope annotation (I don't remember 100% but I think if you don't scope it, it gets generated as a property without a backing field, but I might be wrong).
k
yes. it is how I did for now. but I don't want use scope annotations outside of the component description
e
Did you try putting the scope annotation on the
abstract val
?
Oh sorry, I missed what you're trying to do. That isn't supported, but I think it's supposed to log a warning saying so https://github.com/evant/kotlin-inject/issues/238
What's your use case for not wanting to put the scope annotation on the class?
k
1. i'd like to manage scopes in the component only 2. the same class instances with different lifecycles
e
@evant any thoughts?