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

Change inject-decorators API #1481

Open
dustinlacewell opened this issue Oct 12, 2022 · 1 comment
Open

Change inject-decorators API #1481

dustinlacewell opened this issue Oct 12, 2022 · 1 comment

Comments

@dustinlacewell
Copy link

Feel free to reject and close this if you disagree.

I think that the inversify-inject-decorators package should reconsider the design of its API.

Specifically, I think that a Container instance should not be required to create the decorators. This feels like a code-smell to me. It introduces the constraint that you need to create the Container instance during import-time, so that the decorators may be used.

Rarely, if ever, in my Inversify applications, is the Container instance created at import time.

I suggest reworking things so that not only are the decorators returned, but also a function for applying their effects to a given Container instance:

let { lazyInject, applyDecorators } = createDecorators();
// later...
applyDecorators(container);

This is eminently more flexible. Especially once you start generating child containers at runtime, etc.

Thanks for hearing me out. Great work on everything.

@samuelm00
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants