Overview of Dependency Injection
Since Typescript 1.5
introduces the notion of the decorator, you can do meta-programing
using the added metadata provided by using a
decorator on different objects or properties, such as class
, function
, function parameters
or class property
. The meta-programing is the ability to write some code or program using the metadata describing an object. This type of program allows you to modify the functioning of a program using its own metadata. In our case this metadata is of interest to us, because it helps inject some object into another object, whose name is Dependency Injection.
By using the decorator, you can add metadata on any object or property linked to those decorators. This will define, for example, the type of object that takes the decorator, but it can also define all of the parameters
needed by a function that are described in its metadata. To get or define metadata on any object, you can also use the reflect-metadata
library in order to manipulate...