jaredhanson / jaredhanson/electrolyte
Constructor passed an object with dependencies instead of as parameters
- Dominant language
- JavaScript
- Stars
- 555
- Forks
- 60
- PR merge metrics
- No merged PRs in 30d
Description
I was looking to add the feature in myself, but I'm not very clear on your code base and not sure how it would fit in.
As an alternative to passing in dependencies to a constructor as each dependency being a parameter, and thus possibly creating a very unwieldy constructor signature, it would be nice if the dependencies could be passed in as an object.
As an example:
``` javascript
exports = module.exports = function(deps) {
...
};
exports['@requireObj'] = [ 'foo', 'bar' ];
```
And then `deps` would look like:
``` javascript
{
foo: {},
bar: {} // or whatever the instance is supposed to be
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing how constructors receive dependencies and how the @requireObj metadata is interpreted. Define the expected behavior for the foo/bar example, including whether existing parameter-based injection remains supported, then add tests showing that an object of named dependencies is accepted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100