var mockedModule = require.use('some-module', {'fs':
require('smart-fs'), 'path': require('smart-path'), ...})

That would make more sense, wouldn't it?

On Fri, Jul 27, 2012 at 5:17 PM, Eldar <[email protected]> wrote:
> Did you actually have a look at the code behind? I you really find this
> (both implementation and rules introduced) adding complexity?
>
>
> On Friday, July 27, 2012 7:07:12 PM UTC+4, Rob Ashton wrote:
>>
>> Do we need dependency injection in nodejs? Well - if you mean dependency
>> injection literally, we have it already, it looks like this
>>
>> function doSomething(dependency) {
>>
>> }
>>
>> doSomething(new FooDependency())
>>
>> or
>>
>> doSomething(new BarDependency())
>>
>> or
>>
>> var Animal = function(vocals) {
>>   this.vocals = vocals
>> }
>>
>> var cat = new Animal(miaow)
>> cat dog = new Animal(woof)
>>
>> etc
>>
>> ----------
>>
>> If you're talking about  'container' support to support this, it's a road
>> that has been trodden well by .NET and Java devs, and has been shown time
>> and time again to lead full circle to the very beginning where you just
>> build your object graphs manually and introduce extensibility points where
>> you need them for either mocking out slow dependencies for testing or
>> allowing consumers to control something about your code.
>>
>> Trying to bake in support to this as part of the require system seems like
>> asking for trouble, keep it explicit, keep it as needed and let the goodness
>> follow.
>>
>> My two cents.
>>
>>
>> On Fri, Jul 27, 2012 at 4:45 PM, Eldar <[email protected]> wrote:
>>>
>>> Do we need this in Node?
>>>
>>> My answer is yes we need some (simple) way to specify the app level
>>> dependencies  at runtime. Here is my take on this. Please checkout and let
>>> me know how do you feel about.
>>>
>>> But the idea is very simple:
>>>
>>> // inside any index.js
>>> var R = require('runtime').patchNative()
>>> var use = R(module).use
>>>
>>> use('fs', 'node_modules/third/party', require('./smart-fs'))
>>>
>>> That's it. Third party module just uses our smart file system
>>>
>>> --
>>> Job Board: http://jobs.nodejs.org/
>>> Posting guidelines:
>>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>>> You received this message because you are subscribed to the Google
>>> Groups "nodejs" group.
>>> To post to this group, send email to [email protected]
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>> For more options, visit this group at
>>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>
>>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en



-- 
Oliver Leics @ G+
https://plus.google.com/112912441146721682527

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to