Created
December 27, 2013 10:01
-
-
Save scribblet/8144836 to your computer and use it in GitHub Desktop.
Closure form of DI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//makeThumbnail.js | |
module.exports = function(db) { | |
db = db || require('./database.js'); | |
return { | |
start : function(input){ | |
// makeThumbnail | |
// save timestamp | |
db.save({...}); | |
} | |
}; | |
//and it would be used like this in taskRunner.js and tests: | |
var db = require('./database.js'), | |
makeThumbnail = require('./tasks/makeThumbnail')(db); | |
//End usage won't be cluttered with dependency injection with this. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment