@unlib-js/depi • Docs
@unlib-js/depi / decorators/DependsOn
DependsOnOptions<
T
>: keyofInstanceType
<T
>[] |object
Type Parameter |
---|
T extends AnyConstructor |
default<
T
>(opts
): (clazz
) =>undefined
|T
A decorator that tracks the dependencies of a class.
This dependency information can be used to indicate that the decorated class should be destroyed before its dependencies.
It achieves this by doing the following:
- Wrap the constructor to store dependencies in the constructor's parameters
specified by
opts.params
in the[symbols.ctorDeps]
property. - Add the dependencies in properties specified by
opts.props
to the metadata on the class.
Type Parameter |
---|
T extends AnyConstructor |
Parameter | Type | Description |
---|---|---|
opts |
DependsOnOptions <T > |
An array of property keys or an object describing the properties and constructor parameters that the decorated class depends on. |
Function
A decorator function that can be applied to a class.
Parameter | Type |
---|---|
clazz |
T |
undefined
| T