Hi all! I started using annotations on my projects...
# koin
n
Hi all! I started using annotations on my projects and it really cleans up the code 🙂 Maybe it's lack of knowledge but there are a few simple use cases where I still need to use the DSL because some definitions depend on the properties of other definitions, so the module looks like:
Copy code
@Single
class ComponentA { ... }

module {
    single { ComponentB(get<ComponentA>().foo) }
}
For these simple mappings it would be really cool if we could do something like:
Copy code
@Single
class ComponentB(@InjectedFrom(ComponentA::foo::class) foo: Foo)
Is there a way to do this already with annotations? If not, do you think this proposal is reasonable?
I'll leave the question here but in the meanwhile I read a bit more about the Koin annotations and I guess it's just cleaner and more simple to declare a factory function in the module class and do that mapping there.
a
Perhaps, you just need to inject ComponentA and then extract inside your class the needed propperty?
else just declare the binding in Koin
n
The issue is ComponentB should not be aware of ComponentA, only Foo. But the second option works fine.