<!channel>: I was asked about scopes in Injekt. H...
# kohesive
a
<!channel>: I was asked about scopes in Injekt. Here are a few notes about what you can do now, and what I was thinking about adding. Now, you can create a local scope any time you want:
Copy code
val myLocalScope: InjektScope = InjektScope(DefaultRegistrar())
And it is a standalone scope. You can also register singleton factories, or other factories that delegate to another scope:
Copy code
// delegate some factories to global Injekt instance
myLocalScope.addSingletonFactory { Injekt.get<SomeSingletonClass>() }
myLocalScope.addFactory { Injekt.get<SomeMultiValueClass>() }
And you have delegation. For the singleton you would have a reference to the object in both scopes, the multi value not since those instances are not remembered. For keyed multi value, or thread by key, you would also have both referencing the instances. So you can do some linked scopes with you in full control. This could be used in Android per activity class where you create a local activity scope that delegates only some factories to the global scope that it decides should be available, and the rest it defines locally. But that may not be enough for people.