-
Notifications
You must be signed in to change notification settings - Fork 67
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
Access services in a decorator #67
Comments
If I follow you correctly, you want to be able to inject additional services into a decorator; basically the decorator would have it's own dependencies. Is that correct? |
That is correct! |
This makes sense to me; sounds like a good addition. Probably should add the feature to middleware as well. Possibly also add injection to factories, but not sure. |
In case it helps, the use case is an npm module where I export a bottle container. Other modules can then consume these services but in some cases may either override or augment existing functionality. It's a flexible architecture but, at the moment, decorating an existing service is constrained to services you can access using |
@young-steveo yes, injection into factories, decorators and middleware is very nice... For decorators think of something more or less that might want to hook an event on something else...
|
@mwillbanks Yeah, I'm going to get started on the new Bottle version soon; I'll include this feature. I hadn't considered putting the injectables before the final function, but I like the idea, thanks! |
Just as an FYI to any poor soul needing this solution, I've implemented the following which works well. It isn't pretty but beauty is skin deep.
|
I've not thought this through fully, but is there a good reason not to allow access to dependencies in a decorator? I've had a few situations where I want to alter/augment some behaviour in a given service, but from the decorator I'm very limited in what I have access to.
Something like
The text was updated successfully, but these errors were encountered: