Create beans non-scoped inside a scope, make any s...
# koin
p
Create beans non-scoped inside a scope, make any sense? Eg.:
Copy code
val module = module {
   scope<MainActivity> {
      single<FancyObject1> { FancyObject1() } 
      factory<FancyObject2> { FancyObject2() } 
   }
}
p
I would say yes. You may not want to reuse the same bean instance in a scope. You may want to create fresh instances per request. Now, I see your point, why not place the factory globally 🤔 unless you want to limit the scope of the factory itself. But yeah in practicality makes no much sense
l
Personally, I rarely split to different scopes
a
you can use factory inside scope for visibility purpose, to avoid expose this factory elsewhere
👍 3
p
If I want multiple instances for every get, factory will work. And outside of scope, that won't work. Yeah... now make sense.
1