Dependency Injection
Appolo has a powerful Dependency Injection system based on @appolo/inject.
It enables you to write organised, testable code based on the loose coupling pattern.
You can always access the injector via app.injector or inject it @inject() injector.
Usage#
Constructor Injection#
Using constructor injection or method parameter injection
info
It is not recommended to inject objects to constructor because it can lead to circular reference.
Property Injection#
Using property injection it is possible to inject circular references
Inherited injections#
Inherited injections supported as well.
Anything you inject on a base class will be available to child classes.
Remember not to use
@defineon the parent class.
Override#
you can to register 2 classes with the same id but sometimes it's need to override the registered class for example in testing env