-
Notifications
You must be signed in to change notification settings - Fork 23
feat: add mechanics to provide classes and factories with internally registered tokens #68
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
base: master
Are you sure you want to change the base?
Conversation
This is very interesting. I've got a couple of remarks.
Sorry it took me so (incredibly) long to review. I didn't see this PR for years. |
Thank you for the reply, and no worries on the delay.
I will update this pull request soon, and let you know. Off-topic: Since you mentioned |
Thanks! I will keep an eye on this :)
I've been thinking about |
BREAKING CHANGE: Please use Node 18 or higher
- Simplify error messages - Allow for near-infinite deep dependency trees. Co-authored-by: Nico Jansen <[email protected]>
Add a new function to create a child injector, named `createChildInjector`. Contrary to its `provideXxx` counterparts,this will create a new disposable scope without providing additional injectable values.
…nicojs-master-2
Hi @nicojs ! How have you been? I finally got around to implementing the changes we talked about before. So sorry for the delay! I have given it some thought and went with your original suggestion of calling this new property "knownAs", and subsequently calling this mechanics "Known Classes" and "Known Functions". So as previously agreed:
Please review this when you can, and let me know what you think. Particularly, about the branding of this feature. Cheers! |
🏷️ Internally registered tokens / Known Classes and Known Factories
You can register class tokens internally in the classes that need to be provided, and then provide such classes by using the
provideClass
method's overload. To implement the "Known Class", add astatic knownAs
property with a string literal value. This way, it is possible to create a hierarchy of class dependencies without relying on arbitrarily specified tokens, instead opting to consolidate said tokens within the classes themselves.Similarly, it works with
provideFactory
method's overload.