Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for defining @Components in @Configuration classes #20

Open
saskodh opened this issue Jul 14, 2016 · 0 comments
Open

Add support for defining @Components in @Configuration classes #20

saskodh opened this issue Jul 14, 2016 · 0 comments

Comments

@saskodh
Copy link
Owner

saskodh commented Jul 14, 2016

Background

The @configuration classes should provide way for manually creating the components in the DI container. This is really important especally for instances of classes which cannot be decorated with @component and picked-up by the @componentscan.

Goal

Add support for creating components from the methods in @configuration classes decorated with @component similar like Spring. For more info check the Spring documentation on configuration classes (Link).

Task

Extend @component decorator so it can be used also on methods in @configuration classes

Implementation detail: TypeScript has few types of decorators depending on the place where they are used. They can be differentiated by the arguments that are passed to the decorator function. That means that we can create a universal decorator that can be used on all places. In this patch I wrote a small util that can infer the decorator type from it's arguments.

Note:

  • @Inject and @value should also work in @configuration classes -> in that way we can get the dependencies from imported configuration classes
  • @configuration class needs to be proxied in order to respect the component scope -> local dependencies will be fetched by calling the component definition method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant