Scopes¶
A scope is a special object that controls dependency creation. It decides if new dependency instance should be created, or some cached instance should be returned.
By default, there are two scopes registered in haps:
InstanceScope
and SingletonScope
as haps.INSTANCE_SCOPE
and haps.SINGLETON_SCOPE
.
The haps.INSTANCE_SCOPE
is used as a default.
You can register any other scope by calling
haps.Container.register_scope()
. New scopes should be a subclass
of haps.scopes.Scope
.
-
class
haps.scopes.instance.
InstanceScope
[source]¶ Dependencies within InstanceScope are created at every injection.