TSDI
constructor
new TSDI();
addLifecycleListener
addLifecycleListener(lifecycleListener: LifecycleListener): void;
Register a LifecycleListener in this instance. This listeners will be called whenever a component is created or destoryed.
addProperty
addProperty(key: string, value: any): void;
Add a simple property as injectable to the container instance. This should mainly be used to setup configuration and other simple properties.
close
close(): void;
Shutdown this TSDI instance and destroys all created components.
enableComponentScanner
enableComponentScanner(): void;
Enables component scanner mode.
enableAutomock
enableAutomock(...allowedDependencies: any[]): void;
Enables automock mode.
register
register(component: Constructable<any>, name?: string): void;
Registers component
as Component in this instance.
If name
is given it could be used for name based injection.
mock
mock<T>(component: Constructable<T>): Mock<T>;
The mock method could be used to customize an automock
of the given component
. This only works if automocks are enabled.
get
get<T>(componentOrHint: string | Constructable<T>): T;
get<T>(component: Constructable<T>, hint: string): T;
Creates and returns a component of type T
from this instance.
If hint
is given name based injection
is used for component resolution.
override
override(component: Constructable<any>, override: any): void;
Overrides the component
with override
on all subsequent get()
calls.
This simplifies mocking in tests a lot.
getScope
getScope(name: string): {
enter(): void;
leave(): void;
};
Returns the name
d scope which could then be entered or left.