Decorators
@system-inc/base-foundation · 515c140 · 13 symbols
@ContainerScoped
Class decorator factory that will cause the dependency container to return the same instance each time a resolution for this dependency is requested. This is similar to being a singleton, however if a child container is made, that child container will resolve an instance unique to it.
Accepts an optional BaseModuleKey declaring module membership —
see Injectable.
@Inject
Parameter decorator factory that allows for interface information to be stored in the constructor's metadata.
Accepts a TypedInjectionKey<T> in addition to the standard tsyringe
InjectionToken<T> shapes; the typed key carries the resolved type
for static verification by the base/inject-type-matches-parameter
lint rule.
@Injectable
Class decorator factory that allows the class' dependencies to be injected at runtime.
Uses the default registration scope: Transient. A new instance will be created with each resolve
Pass a BaseModuleKey to declare the class a member of that module.
Membership drives module-aware database resolution: token-less
@InjectRepository/@InjectDatabase parameters in the class resolve to
the database the module resolves to in the running worker (the module's
orm.databaseName, as overridden by the worker's database registration
modifier). All the injectable-family decorators (@Singleton,
@WorkerScoped, @ContainerScoped, @ResolutionScoped) accept the same
optional key.
@InjectAll
Parameter decorator factory that resolves all registrations for the given token as an array.
Accepts TypedInjectionKey<T> and any TypedBinding subclass in
addition to the standard tsyringe token shapes.
@InjectAllOptional
Inject an array of optional dependencies.
@InjectAllWithTransform
Parameter decorator factory that resolves all registrations through a transform.
tokenThe token of the object to be resolved.
transformerThe transform class.
argsArguments passed to the transform method.
@InjectLazy
Inject a lazy dependency.
@InjectOptional
Inject an optional dependency.
@InjectWithTransform
Parameter decorator factory that resolves a token through a transform before injection.
tokenThe token of the object to be resolved.
transformerThe transform class.
argsArguments passed to the transform method.
@Provider
Registers the decorated method as a provider for the specified token.
When the token is resolved, the method will be called and the result will be returned.
@ResolutionScoped
Class decorator factory that will cause the dependency container to use the same instance to be resolved for each resolution of this dependency during a single resolution chain.
Accepts an optional BaseModuleKey declaring module membership —
see Injectable.
@Singleton
Class decorator factory that registers the class as a singleton within the global container.
Each resolve will return the same instance (including resolves from child containers), from the global scope.
Accepts an optional BaseModuleKey declaring module membership —
see Injectable.
You probably want to use @ContainerScoped or @WorkerScoped() instead.
@WorkerScoped
Class decorator factory that registers the class with the @worker scoped container.
Each resolve will return the same instance (including resolves from child containers),
from the @worker scope.
Accepts an optional BaseModuleKey declaring module membership —
see Injectable.
Very similar to @Singleton, but scoped to the worker instead of globally.