Class: ScopedContainer
Defined in: src/DI/scoped-container.ts:14
Hierarchical DI container that supports parent-chain resolution.
Each component with services: [...] in its
Component
config gets a ScopedContainer. Services not found locally are resolved by walking up the parent chain.
Uses topological sort (Kahn’s algorithm) to bootstrap services in correct dependency order — same algorithm as DIContainer.
Constructors
Constructor
new ScopedContainer(parent?: ScopedContainer): ScopedContainer;
Defined in: src/DI/scoped-container.ts:25
Parameters
| Parameter | Type |
|---|---|
parent? |
ScopedContainer |
Returns
ScopedContainer
Accessors
isReady
Get Signature
get isReady(): boolean;
Defined in: src/DI/scoped-container.ts:202
Check if bootstrap has been called.
Returns
boolean
parent
Get Signature
get parent(): ScopedContainer | undefined;
Defined in: src/DI/scoped-container.ts:209
Get the parent container.
Returns
ScopedContainer | undefined
Methods
bootstrap()
bootstrap(): Promise<void>;
Defined in: src/DI/scoped-container.ts:146
Bootstrap all locally registered services, awaiting async onBootstrap hooks. Use this in the DOM init() path where async is available.
Returns
Promise<void>
bootstrapSync()
bootstrapSync(): void;
Defined in: src/DI/scoped-container.ts:123
Bootstrap all locally registered services in dependency order. Each instance is associated with this container via __container.
Services with async onBootstrap() are launched as fire-and-forget. Use the reactive pattern (@Store with isLoading) to handle async state.
Returns
void
dispose()
dispose(): void;
Defined in: src/DI/scoped-container.ts:224
Dispose all local services and reset container. Calls onDestroy() on services that implement it.
Returns
void
get()
get<T>(ctor: Constructor<T>): T;
Defined in: src/DI/scoped-container.ts:166
Resolve a service by walking up the parent chain. Checks local scope first, then parent, then grandparent, etc.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type |
|---|---|
ctor |
Constructor<T> |
Returns
T
getAllInstances()
getAllInstances(): any[];
Defined in: src/DI/scoped-container.ts:216
Get all locally instantiated service instances.
Returns
any[]
has()
has(ctor: Constructor): boolean;
Defined in: src/DI/scoped-container.ts:186
Check if a service exists in this scope or any parent scope.
Parameters
| Parameter | Type |
|---|---|
ctor |
Constructor |
Returns
boolean
hasLocal()
hasLocal(ctor: Constructor): boolean;
Defined in: src/DI/scoped-container.ts:195
Check if a service is registered locally (not including parents).
Parameters
| Parameter | Type |
|---|---|
ctor |
Constructor |
Returns
boolean
register()
register(token: Constructor): void;
Defined in: src/DI/scoped-container.ts:32
Register a service constructor in this scope
Parameters
| Parameter | Type |
|---|---|
token |
Constructor |
Returns
void
registerDependency()
registerDependency(parent: Constructor, dependency: Constructor): void;
Defined in: src/DI/scoped-container.ts:48
Register a dependency relationship between services in this scope. Only for dependencies that are BOTH registered locally. Cross-scope dependencies are resolved via parent chain at get() time.
Parameters
| Parameter | Type |
|---|---|
parent |
Constructor |
dependency |
Constructor |
Returns
void