@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

    Constructors

    Properties

    @injectable decorator factory bound to this injector instance.

    Methods

    • 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.

    • 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.

    • 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

      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<
                { [K in string
                | number
                | symbol]: NullableQualifier<Params[K]> },
            >,
            Value,
        > & {
            inject: NoInfer<
                { [K in string
                | number
                | symbol]: NullableQualifier<Params[K]> },
            >;
            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