Module scope

Module scope 

Source
Expand description

Component instances are contained in Scopes - containers which decide when to reuse or create an instance. There’s a global one for singletons, but there also can be other, specialized ones. Some can be simple, like PrototypeScope, while other can be quite complex and depend on external factors, e.g. tying the lifetime of instances to web sessions.

Note: scope resolution happens at component instantiation time, which can lead to unexpected consequences if incompatible scopes are mixed together, e.g. a singleton component can depend on a prototype one. In such case when creating the singleton, a new instance of the dependency will be created, since it’s a prototype, but then that single instance will live as long as the singleton lives.

Structs§

PrototypeScope
A scope which creates a new instance of a given component on each request. Stateful components usually should be stored in a prototype scope.
PrototypeScopeFactory
SingletonScope
Scope for instances shared between components. Stateless components are good candidates to be stored in the singleton scope.
SingletonScopeFactory

Constants§

PROTOTYPE
Name of the PrototypeScope.
SINGLETON
Name of the SingletonScope.

Traits§

Scope
A scope containing component instances. See module documentation for information on scopes.
ScopeFactory
Factory for custom Scopes.

Type Aliases§

ScopePtr