class DependableTrait
Language | Type name |
---|---|
.NET | Amazon.CDK.DependableTrait |
Java | software.amazon.awscdk.core.DependableTrait |
Python | aws_cdk.core.DependableTrait |
TypeScript (source) | @aws-cdk/core » DependableTrait |
Trait for IDependable.
Traits are interfaces that are privately implemented by objects. Instead of showing up in the public interface of a class, they need to be queried explicitly. This is used to implement certain framework features that are not intended to be used by Construct consumers, and so should be hidden from accidental use.
Example
// Usage
const roots = DependableTrait.get(construct).dependencyRoots;
// Definition
class TraitImplementation implements DependableTrait {
public readonly dependencyRoots: IConstruct[];
constructor() {
this.dependencyRoots = [constructA, constructB, constructC];
}
}
DependableTrait.implement(construct, new TraitImplementation());
Initializer
new DependableTrait()
Properties
Name | Type | Description |
---|---|---|
dependency | IConstruct [] | The set of constructs that form the root of this dependable. |
dependencyRoots
Type:
IConstruct
[]
The set of constructs that form the root of this dependable.
All resources under all returned constructs are included in the ordering dependency.
Methods
Name | Description |
---|---|
static get(instance) | Return the matching DependableTrait for the given class instance. |
static implement(instance, trait) | Register instance to have the given DependableTrait. |
static get(instance)
public static get(instance: IDependable): DependableTrait
Parameters
- instance
IDependable
Returns
Return the matching DependableTrait for the given class instance.
static implement(instance, trait)
public static implement(instance: IDependable, trait: DependableTrait): void
Parameters
- instance
IDependable
- trait
Dependable
Trait
Register instance
to have the given DependableTrait.
Should be called in the class constructor.