Joe
02/26/2018, 3:52 PMstreetsofboston
02/26/2018, 3:55 PMobject
that implements your custom Scope and use that for your dependency definitions. Then access that object
to ‘clear it out’ when needed.streetsofboston
02/26/2018, 3:55 PMJoe
02/26/2018, 3:56 PMstreetsofboston
02/26/2018, 4:02 PMmyScope
as the Scope for the dependencies you’d like to be able to throw away.
object myScope: Scope<SomeContext> {
override fun getRegistry(context: SomeContext): ScopeRegistry {
...
}
fun clear() {
...
}
}
And when you want to ‘throw it away’ call clear
.
myScope.clear()
Joe
02/26/2018, 4:03 PMstreetsofboston
02/26/2018, 5:06 PMConfigurableKodein
and re-create your dependencies (that is what I use for running unit-tests).
Also, consider using plain `Scope`s or tags if you need to get a different dependency (singleton) given a different context of your app.
The hack of ‘clearing’ your Scope is just that, a hack… 🙂