wirebox
    Preparing search index...

    Class Circuit

    A circuit is a container which is responsible for managing the instances by holding and initializing them.

    Only one instance of a class can exist in a circuit.

    Index

    Constructors

    Methods

    • Get the instance of the given class.

      NOTICE: This method is a low-level operation as it does not instantiate classes or resolve providable classes. Use it with caution.

      Type Parameters

      Parameters

      • target: TTarget

        The class to get the instance for.

      Returns ResolvedInstance<TTarget> | undefined

      The instance of the class, or undefined if not found.

    • Installing means to manually add an instance to the circuit. The installed instance class also doesn't need to be wired because you are responsible for initializing it.

      For example, when a circuit is created, it installs itself as an instance. With this, it is possible to use the circuit class as an input.

      You can use this to manually add instances you already have initialized.

      Type Parameters

      Parameters

      Returns InstanceType<TTarget>

      The instance that was installed.

    • Check if the given class has async initializer or provides an async value.

      Classes without an async initializer will be instantiated if not yet initialized in the circuit. This is necessary to receive possible provider info.

      Parameters

      • target: Class

        The class to check.

      Returns boolean

      True if the class has async initializer or provides an async value, false otherwise.

    • Check if the given class is installed (initialized) in this circuit.

      Parameters

      • target: Class

        The class to check.

      Returns boolean

      True if the class is installed (initialized), false otherwise.

    • Uninstalling means to manually remove an instance from the circuit.

      This method should be used with caution!

      Type Parameters

      Parameters

      • target: TTarget

        The class of the instance to uninstall.

      Returns InstanceType<TTarget> | undefined

      The instance that was uninstalled, or undefined if not found.