import { type WritableContainer } from "https://deno.land/x/lambda_ioc@1.0.0/lambda-ioc/deno/index.ts";
Represents a write-only version of a type-safe IoC container with "auto-wired" dependencies resolution.
Methods
register<TName extends ConstrainedKey, TDependency extends TName extends keyof TSyncDependencies ? TSyncDependencies[TName] : TName extends "$" | keyof TAsyncDependencies ? never : unknown>(name: TName, dependency: SyncDependencyFactory<TDependency, ReadableSyncContainer<TSyncDependencies>>): Container<[TK in keyof TSyncDependencies | TName]: TK extends keyof TSyncDependencies ? TName extends TK ? TDependency : TSyncDependencies[TK] : TDependency, TAsyncDependencies>
Registers a new synchronous dependency factory.
It cannot be used when self-resolution is needed. Use
registerConstructor
instead.
registerAsync<TName extends ConstrainedKey, TDependency extends TName extends "$" | keyof TSyncDependencies ? never : TName extends keyof TAsyncDependencies ? TAsyncDependencies[TName] : unknown>(name: TName, dependency: AsyncDependencyFactory<TDependency, ReadableContainer<TSyncDependencies, TAsyncDependencies>>): Container<TSyncDependencies, [TK in keyof TAsyncDependencies | TName]: TK extends keyof TAsyncDependencies ? TName extends TK ? TDependency : TAsyncDependencies[TK] : TDependency>
Registers a new asynchronous dependency factory.
It cannot be used when self-resolution is needed. Use
registerAsyncConstructor
instead.
registerConstructor<TName extends ConstrainedKey, TParams extends (): Container<[TK in keyof TSyncDependencies | TName]: TK extends keyof TSyncDependencies ? TName extends TK ? TClass : TSyncDependencies[TK] : TClass, TAsyncDependencies>
)[], TClass extends TName extends "$" | keyof TAsyncDependencies ? never : TName extends keyof TSyncDependencies ? TSyncDependencies[TName] : unknown, TDependencies extends ContextualParamsToSyncResolverKeys<TSyncDependencies, TAsyncDependencies, TParams>>(
name: TName,
constructor: new (...args: TParams) => TClass,
...args: TDependencies,
registerAsyncConstructor<TName extends ConstrainedKey, TParams extends (): Container<TSyncDependencies, [TK in keyof TAsyncDependencies | TName]: TK extends keyof TAsyncDependencies ? TName extends TK ? TClass : TAsyncDependencies[TK] : TClass>
)[], TClass extends TName extends "$" | keyof TSyncDependencies ? never : TName extends keyof TAsyncDependencies ? TAsyncDependencies[TName] : unknown, TDependencies extends ContextualParamsToAsyncResolverKeys<TSyncDependencies, TAsyncDependencies, TParams>>(
name: TName,
constructor: new (...args: TParams) => TClass,
...args: TDependencies,
Registers a new constructor that might have asynchronous-resolvable dependencies. This method is helpful when the constructor combinator is not powerful enough (as it's only able to resolve synchronously, and it cannot take advantage of self-resolution either).
registerValue<TName extends ConstrainedKey, TDependency extends TName extends keyof TSyncDependencies ? TSyncDependencies[TName] : TName extends "$" | keyof TAsyncDependencies ? never : unknown>(name: TName, dependency: TDependency): Container<[TK in keyof TSyncDependencies | TName]: TK extends keyof TSyncDependencies ? TName extends TK ? TDependency : TSyncDependencies[TK] : TDependency, TAsyncDependencies>
Registers an already instantiated dependency.