@searsuite/sear-foundation-di
Editor-scoped dependency injection with explicit ownership and borrowed instances.
- enumScope
-
Enumerates Scope values.
enum member Prototype: 1enum member Singleton: 0 - classContainer
-
Dependency container.
Composition roots create and own explicit instances. Stateful runtimes must never share a process-wide container because resetting or rebinding one runtime would otherwise affect every other live runtime.
constructor Container(): Containerproperty readonly types: Map<any, any>Registered dependency tokens owned by this container.
method addDependency(parent: symbol, dependency: string | symbol): voidAdds the dependency.
method createLazy<T>(identifier: string): (): TCreates the lazy.
method destroy(): voidmethod dispose(): voidmethod getDependency(): voidReturns the dependency.
method getDependencyGraphText(): voidReturns the dependency graph text.
method hasBinding(identifier: string | symbol): booleanReturns whether this container has an explicit local binding for an identifier.
method hasSingleton(identifier: string | symbol): booleanReturns whether a singleton has already been materialized for an identifier.
method register<T>(identifier: Identifier<T>, clazz: Constructor<T>, scope?: Scope): voidRegisters the value.
method registerBorrowedInstance<T>(identifier: Identifier<T>, instance: T): voidBinds a parent-owned instance without acquiring its teardown responsibility.
method registerFactory<T>(identifier: Identifier<T>, factory: FactoryFunction<T>, scope?: Scope): voidRegisters the factory.
method registerInstance<T>(identifier: Identifier<T>, instance: T): voidRegisters the instance.
method registerTypes(module: symbol, types: { }): voidRegisters the types.
method reset(): voidReleases created resources and removes every registration from this container.
method resolve<T>(identifier: string | symbol): TResolves a dependency from this container and its parent scope.
- variableINJECT_METADATA_KEY
-
INJECT_METADATA_KEY: typeof INJECT_METADATA_KEYMetadata key storing constructor parameter injection tokens.
- variableINJECTABLE_METADATA_KEY
-
INJECTABLE_METADATA_KEY: typeof INJECTABLE_METADATA_KEYMetadata key that marks a class as resolvable by the DI container.
- functionInject
-
Inject(identifier: unknown): ParameterDecoratorRecords the DI token that should satisfy one constructor parameter.
ReturnsParameter decorator used on constructor arguments.
identifierToken registered in the DI container.
- functionInjectable
-
Injectable(): ClassDecoratorMarks a class as injectable by the DI container.
ReturnsClass decorator that records injectable metadata.
- functionSingleton
-
Singleton(): ClassDecoratorMarks a class as injectable and singleton-scoped.
ReturnsClass decorator that records singleton and injectable metadata.
No matching API entries.