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 InjectionUsing constructor injection or method parameter injection
info
It is not recommended to inject objects to constructor because it can lead to circular reference.
#
Property InjectionUsing property injection it is possible to inject circular references
#
Inherited injectionsInherited injections supported as well.
Anything you inject on a base class will be available to child classes.
Remember not to use
@define
on the parent class.
#
Overrideyou can to register 2 classes with the same id but sometimes it's need to override the registered class for example in testing env