Skip to content

Instantly share code, notes, and snippets.

@cjohansen
Created January 6, 2016 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cjohansen/ae729aef360a724b2a59 to your computer and use it in GitHub Desktop.
Save cjohansen/ae729aef360a724b2a59 to your computer and use it in GitHub Desktop.
Some people call this "dependency injection", I call it "passing arguments"
var connect = require('my-connector');
var dep1 = require('dep1');
var dep2 = require('dep2')
exports.default = function (config) {
var connection = connect(config);
var myDep1 = dep1.init(connection);
var myDep2 = dep2.init(connection);
return {
doIt: function () {
// Do interesting things with myDep1 and myDep2
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment