Working of Dependency Injector or Container

less than 1 minute read

Dependency Injection Container or Injector is basically a static or global thing which is being used throughout the app to inject dependencies or objects. It knows how to incorporate and configure dependencies. To do this, it needs information about the constructor arguments and the relationships between the objects. In simple words, A Dependency Injection Container manages objects right from their instantiation to their configuration. Its main responsibilities are classified as:

  • Owning map or container which stores info about token & dependencies.
  • Creating the objects or dependencies.
  • To identify which classes require those objects – Maintaining the scope.
  • Provide all those objects to required classes – Injecting

If there is any change in objects, then Dependency Container looks into it without disturbing or affecting the concerned class using those objects. In this way in case of any future change also, Dependency Injector takes responsibility to provide the appropriate objects to the class.

To know more on DI Container working and its responsibilities, visit our tutorial video 0008-4- What is Dependency Injection Container or Injector?