std.resolve
.
Simply decorate the class with @Injectable
and it will start participating in dependency injection.
Moreover, metz will take care of creating the entire dependency graph for you.
So to increase complexity for the sake of it, let’s divide our hello world Main
class example into two classes.
So it should look like this:
You can use DI to make this representation easy:
new
to create instances manually, regardless if the class is part of DI container or not.
This is best suited for scenarios where you need multiple instances of the same thing. For example the Poller
in Introduction
needs to have 2 instances.
new
, you can see this in the code on playground as well.
@Injectable
class can create
instances of classes.
You can see how the system behaves when the two approaches are used simulatenously.