@kayahr/di
    Preparing search index...

    Class Injector

    Dependency injector operating on explicit scopes, or on the shared root scope when no scope is specified.

    Index

    @injectable decorator factory bound to this injector instance.

    • Checks if the given scope or one of its parent scopes can resolve the given registered function.

      Type Parameters

      • Params extends unknown[]

        The original function parameter types.

      • Return

        The function return type.

      Parameters

      • fn: (...params: Params) => Return

        The registered function qualifier to look for.

      • Optionaloptions: ResolveOptions

        Optional resolve options.

      Returns boolean

      True if the function can be resolved, false if not.

    • Checks if the given scope or one of its parent scopes can resolve the given class or injection token.

      Type Parameters

      • Value

        The provided dependency type.

      Parameters

      Returns boolean

      True if the qualifier can be resolved, false if not.

    • Removes the given registered function from the target scope's registry only and does not bubble up the parent chain.

      Type Parameters

      • Params extends unknown[]

        The original function parameter types.

      • Return

        The function return type.

      Parameters

      • fn: (...params: Params) => Return

        The registered function qualifier to remove.

      • Optionaloptions: ResolveOptions

        Optional resolve options.

      Returns boolean

      True if something was removed, false if not.

      InjectionError when the cached singleton instance requires asynchronous disposal.

    • Removes the given class or injection token from the target scope's registry only and does not bubble up the parent chain.

      Type Parameters

      • Value

        The provided dependency type.

      Parameters

      Returns boolean

      True if something was removed, false if not.

      InjectionError when the cached singleton instance requires asynchronous disposal.

    • Asynchronously removes the given registered function from the target scope's registry only and does not bubble up the parent chain.

      Type Parameters

      • Params extends unknown[]

        The original function parameter types.

      • Return

        The function return type.

      Parameters

      • fn: (...params: Params) => Return

        The registered function qualifier to remove.

      • Optionaloptions: ResolveOptions

        Optional resolve options.

      Returns Promise<boolean>

      Promise resolving to true if something was removed, or false if not.

    • Asynchronously removes the given class or injection token from the target scope's registry only and does not bubble up the parent chain.

      Type Parameters

      • Value

        The provided dependency type.

      Parameters

      Returns Promise<boolean>

      Promise resolving to true if something was removed, or false if not.

    • Registers a class with no constructor parameters.

      Type Parameters

      • Value

        The created dependency type.

      Parameters

      Returns this

    • Registers a class with fully injected constructor parameters.

      Type Parameters

      • Value

        The created dependency type.

      • Params extends unknown[]

        The constructor parameter types.

      Parameters

      Returns this

    • Registers a transient class whose constructor may use null pass-through placeholders.

      Type Parameters

      • Value

        The created dependency type.

      • Params extends unknown[]

        The constructor parameter types.

      Parameters

      • type: Constructor<Value, Params>

        The class to register.

      • options: InjectableOptions<NoInfer, Value> & { inject: NoInfer; lifetime: 1 }

        Registration options including the injected constructor parameters and transient lifetime.

      Returns this

    • Registers a factory with no parameters.

      Type Parameters

      • Value

        The created dependency type.

      Parameters

      Returns this

    • Registers a factory with fully injected parameters.

      Type Parameters

      • Value

        The created dependency type.

      • Params extends unknown[]

        The factory parameter types.

      Parameters

      Returns this

    • Registers a transient factory whose parameters may use null pass-through placeholders.

      Type Parameters

      • Value

        The created dependency type.

      • Params extends unknown[]

        The factory parameter types.

      Parameters

      • type: Class<Value>

        The type produced by the factory.

      • factory: Factory<Value, Params>

        The factory function to register.

      • options: InjectableOptions<NoInfer, Value> & { inject: NoInfer; lifetime: 1 }

        Registration options including the injected factory parameters and transient lifetime.

      Returns this

    • Registers a token-qualified factory with no parameters.

      Type Parameters

      • Value

        The created dependency type.

      Parameters

      Returns this

    • Registers a token-qualified factory with fully injected parameters.

      Type Parameters

      • Value

        The created dependency type.

      • Params extends unknown[]

        The factory parameter types.

      Parameters

      • token: InjectionToken<Value>

        The sole qualifier under which the factory is registered.

      • factory: Factory<Value, Params>

        The factory function to register.

      • options: Omit<InjectableOptions<NoInfer, Value>, "token" | "provide"> & {
            inject: NoInfer;
        }

        Registration options including the injected factory parameters.

      Returns this

    • Registers a transient token-qualified factory whose parameters may use null pass-through placeholders.

      Type Parameters

      • Value

        The created dependency type.

      • Params extends unknown[]

        The factory parameter types.

      Parameters

      • token: InjectionToken<Value>

        The sole qualifier under which the factory is registered.

      • factory: Factory<Value, Params>

        The factory function to register.

      • options: Omit<InjectableOptions<NoInfer, Value>, "token" | "provide"> & {
            inject: NoInfer;
            lifetime: 1;
        }

        Registration options including the injected factory parameters and transient lifetime.

      Returns this

    • Registers the given injectable function in the target scope. Using null in the inject array defines placeholders for pass-through function parameters. So when injecting a function with inject arguments [ null, Service, null ] the resolved function expects two parameters which are filled into the placeholders while Service is injected automatically.

      Type Parameters

      • Params extends unknown[]

        The original function parameter types.

      • const Inject extends FunctionInject<Params>

        The inject array containing qualifiers and null placeholders.

      • Return

        The function return type.

      Parameters

      Returns this