Skip to main content

Dependency Injections

@DependencyInjection.Inject(
injectable
:InjectableClass | Symbol
)#

This annotation allow to inject a service defined in the module, or a defined Service defined by using the Dependency Injection Service.

Parameters
NameOptionalTypeDefaultsDescription
injectableNoInjectableClass | SymbolInjectable Class or Symbol from declared providers in modules.

Example

import DependencyInjection from '@zerooneit/expressive-tea/services/DependencyInjection';
class TestService {    test() {        console.log('Test');    }}
DependencyInjection.setProvider(TestService);
class TestClass {    @DependencyInjection.Inject(TestService)    testService: TestService;}

@DependencyInjection.InjectNamed(
injectableName
:String | Symbol
)#

Same as Inject this is used to inject a service using how is named when added into the dependency injection container, per default a Class Service constructor name is saved as a name.

Parameters
NameOptionalTypeDefaultsDescription
injectableNameNoString | SymbolRoot Path

Example

import DependencyInjection from '@zerooneit/expressive-tea/services/DependencyInjection';
class TestService {    test() {        console.log('Test');    }}
DependencyInjection.setProvider(TestService, 'aService');
class TestClass {    @DependencyInjection.InjectNamed('aService')    testService: TestService;}