From: mixu <mikito.tak...@gmail.com>
Date: Fri, 27 Jul 2012 22:25:53 -0700 (PDT)
Local: Sat, Jul 28 2012 1:25 am
Subject: Re: Dependency injection for Node.js. What do you think?
I've never really needed to dependency inject into third party modules. If However, I do use dependency injection for (unit) testing my own stuff. var fs = require('fs'); }; module.exports = Foo; Then in the test setup: before: function() { }, after: function() { Foo._setBackend(require('fs')); } The nice part is that the mechanism is trivial and doesn't depend on any external modules or require() patching, without forcing me to make "fs" a part of the interface/params to Foo(). It doesn't work on 3rd party modules, but I haven't needed to do that thus far. Simplest thing that works and all that.. On Friday, July 27, 2012 7:45:48 AM UTC-7, Eldar wrote:
> Do we need this in Node? > My answer is yes we need some (simple) way to specify the app level > But the idea is very simple: > // inside any index.jsvar R = require('runtime').patchNative()var use = R(module).use > That's it. Third party module just uses our smart file system You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||