Reputation: 4292
As per this article https://insert-koin.io/docs/1.0/getting-started/android-scope/ we can create scopes for our objects. This is an example given there.
scope("session") { MyScopePresenter(get())}
My question is that are we allowed to put in multiple definitions per scope? I feel we are not. There is no examples anywhere showing such.
scope("session") {
Something()
AnotherThing()}
This doesn't work . I can only inject AnotherThing() while as something is not injected.
Why does Koin just allow one definition per scope?
Upvotes: 1
Views: 971
Reputation: 5635
When you're adding your declarations to the module { ... }
using the single
, factory
or scope
definitions, internally they create so-called BeanDefinition
object. This bean definition object will provide instances of declared objects. Each BeanDefinition
object will handle one declaration. That means that you should change
scope("session") {
Something()
AnotherThing()
}
into
scope("session") { Something() }
scope("session") { AnotherThing() }
in order to make it work.
Upvotes: 1