Skip to content

Simplify dependency injection syntax in constructor with Reflect API #102

@basedalexander

Description

@basedalexander

Implementing this feature is a great way to learn Reflect API and Typescript decorators. I've provided link to a great article on this topic.

Typescript Decorators and Reflect API

  • Use Reflect API to simplify injection syntax.
  • That can only be possible with Typescript, don't try to apply this feature to es5+.
  • Update docs according to this feature.

@Injectable()
class AppService {
    constructor(private http: HttpService) {} // instead of @Inject(HttpService) private http: HttpService
}

@Injectable()
class HttpService {
    
}

container.register([HttpService, AppService])

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions