@bviale/typescript-di
v1.0.0
Published
A very light library to handle dependency injection with Typescript decorators
Downloads
3
Maintainers
Readme
Dependency Injection decorators for Typescript
A very light library to handle dependency injection with Typescript decorators using the Angular @Service
way.
Resolves the dependencies between services and allow the decorated services to be retrieved using the ServiceLocator
singleton.
Can be used in all kinds of Typescript projects such as React.
Usage
@Service
class LoginService {
}
@Service
class AuthenticationService {
// Will be automatically injected
constructor (private loginService: LoginService) { }
}
const instance = ServiceLocator.instance.getService(AuthenticationService) as AuthenticationService;