Comments (9)
You are right, the main reason is to avoid problems during minification or bundling. The reason it's not implemented is because I simply did not yet have the need for it.
One thing that would have to be decided is what to do with the abbreviation for the nullable facility (since ?
is not a valid part of the name),
from intravenous.
Gotcha. No worries. I already wrote a function that wraps the function and sets $inject based on the parameter names. I think it should be optional.
In coffee-script the following would be equivalent:
# before
MyClass = (something) ->
MyClass.$inject = ["something"]
# after
MyClass = autoInject (something) ->
So you could start with autoInject for lots of things, but if you needed to use an optional dependency you could use the $inject syntax.
from intravenous.
Yes, that sounds like a reasonable solution. I'd want to specify the container though, so probably another method on the container object itself would be a good way to do it.
So instead of get
you'd call autoGet
or something.
from intravenous.
I'm ok with anything, or nothing: I can write something myself.
I'm not sure I understand your last comment. The func.$inject property is independent of the container, right? All I'd like is some way to automatically set the $inject property to match the parameter list of the function. It doesn't seem to have anything to do with the container.
But I can write something myself if you don't feel like adding it to the library. So either way. Thanks!
from intravenous.
Oh, so the autoInject just creates the $inject property instead of actually resolving the object? That's even simpler, yes. Maybe that would be a good candidate for inclusion in the core library.
from intravenous.
+1, getting started with Intravenous in Node.js and missing this.
from intravenous.
@domenic Sorry to hijack intravenous' thunder, because it's an awesome framework, but we ended up rolling our own. https://github.com/idottv/dependable - it's not as powerful as intravenous, but it injects based on the name
from intravenous.
Thunder stolen! :)
Seriously though, it's worth including. I finally have some more time to work on it, so hopefully I can add it asap.
Now, if only I can find out how to restrict @seanhess 's IP range from using it...
from intravenous.
Haha... Take whatever you want from our code of course if it helps.
from intravenous.
Related Issues (20)
- Best practice to combine Intravenous with revealing module pattern.
- Inconsistent behavior with singleton in factory usage.
- How do I handle injection for decorator pattern scenario?
- Registering third party modules HOT 5
- Handle prototypal inheritance
- Singleton broken? HOT 3
- Define Constructor Parameters When Registering? HOT 2
- Es6 Classes: Class constructors cannot be invoked without 'new' HOT 4
- npm install has only the package.json HOT 11
- Store a class instead of an instance HOT 10
- Support for request and session-scoped instances in intravenous
- Please add license HOT 3
- Please release an npm module with the latest fixes HOT 1
- Not working on worker
- non-constructor functions HOT 13
- Disposing of singletons HOT 3
- npm source is minified
- Factories are un-ergonomic HOT 1
- A small typo inside example in Intravenous documentation HOT 1
- How about get by Function rather than key? HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from intravenous.