-
Notifications
You must be signed in to change notification settings - Fork 64
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
Ability to define different aliases for an interface? #35
Comments
btw there's probably better ways of handling this than just coding it inside Auryn e.g. either make the lookup of which alias/shared class to use either be more easily extendible (by moving it to it's own function), or allowing Auryn to use plugins to alter it's behaviour, rather than trying to do everything in Auryn. |
I hadn't thought of that (other ways to incorporate "templates" or "profiles"). A plugin or event system would probably resolve my issues. I'm not against the idea itself, I just couldn't reconcile it with how the existing code was structured. I'll give it some thought and throw some ideas at the wall and we'll see what sticks. |
A first draft of having the Provider info be a plugin to the Injector is here Okay so what I've done is:
Obviously still lots to tidy up, but I'm about to jump on a plane to 'Stralia, so will be offline for a while. |
Awesome. It may take me a day or two before I have the time to sit down and digest everything, but it sounds good. |
Other than the fact that i) The function name sucks ii) The classes in progress get passed to the resolve function as lower case iii) a complete lack of error checking, this doesn't appear to be too horrible a solution. https://github.com/rdlowrey/Auryn/compare/rdlowrey:master...Danack:lookup?expand=1 |
Actually this is a way lighter weight solution: If we really wanted to trim off the last 'InjectionChain'....tbh we could leave this from version 1 until someone really needs it. |
A mere nine years later, as this hasn't been added, it probably never will be. I wrote some words in 7d500bc why not. |
@rdlowrey The other day you asked what features I think are still needed - here is one, which we've discussed this before, but I can't find a link.
Sometimes you need to be able to use different implementations for the same interface, based on external factors.
Most of our code is working fine and so we want the 'Logger' to be inserted to be one that only reports notices at the 'error' level.
However some of our users have reported bugs that we think is being caused by the code in ClassRelatedToReportedBugs, or code that it calls. We want to be able to configure our system so that any 'Logger' created by 'ClassRelatedToReportedBugs' or any of it's dependencies uses a Logger that reports notices at the 'info' level.
I think this does need to be configurable through configuration rather than modifying the code, as that the changes need to be done on a production server without downtime.
For the above case, my fork with it's (marginally crazy) ability to alias/share different classes based on the chain of class constructors solves that problem.
However there are probably other cases where some other solution would be needed e.g.
Wouldn't currently be possible would it?
Obviously not every possible way of configuring which classes are instantiated needs to be supported, or should even if it is possible, however I think the first case above is something that most people would expect to be able to configure.
The text was updated successfully, but these errors were encountered: