@lppedd/di-wise-neo - v0.6.0
    Preparing search index...

    Function injectBy

    • Injects the instance associated with the given class.

      Throws an error if the class is not registered in the container.

      Compared to inject, injectBy accepts a thisArg argument (the containing class) which is used to resolve circular dependencies.

      Type Parameters

      • Instance extends object

      Parameters

      • thisArg: any

        The containing instance, used to help resolve circular dependencies.

      • Class: Constructor<Instance>

        The class to resolve.

      Returns Instance

      class Wand {
      owner = inject(Wizard);
      }

      class Wizard {
      wand = injectBy(this, Wand);
      }
    • Injects the value associated with the given token.

      Throws an error if the token is not registered in the container.

      Compared to inject, injectBy accepts a thisArg argument (the containing class) which is used to resolve circular dependencies.

      Type Parameters

      • Value

      Parameters

      • thisArg: any

        The containing instance, used to help resolve circular dependencies.

      • token: Token<Value>

        The token to resolve.

      Returns Value

      class Wand {
      owner = inject(Wizard);
      }

      class Wizard {
      wand = injectBy(this, Wand);
      }