So the question would be: why an async-driven platform uses sync-driven way
to load modules?

2012/5/15 Marak Squires <marak.squi...@gmail.com>

> require() is a sync call.
>
> If you need an async require ( a require that performs i/o ), you should
> check out a plugin system like Broadway (
> https://github.com/flatiron/broadway )
>
> This will allow you to require modules with an optional .init and .attach
> methods, which can both accept optional callbacks.
>
>
> On Tue, May 15, 2012 at 8:49 AM, Guoliang Cao <gca...@gmail.com> wrote:
>
>> Hi,
>>
>> I'm new to Node.js and wrapping my head around the asynchronous
>> programming model. A question comes to mind is why 'require' itself does
>> not use callbacks like below. I believe IO is involved in require and a lot
>> of things can fail.
>>
>> require('http',
>> function(http){
>>    // do stuff with http
>> },
>> function(error) {
>>    console.log("Failed to load http");
>> });
>>
>>
>> Thanks,
>> Guoliang Cao
>>
>> --
>> 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 nodejs@googlegroups.com
>> To unsubscribe from this group, send email to
>> nodejs+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>
>
>
>
> --
> --
> Marak Squires
> Co-founder and Chief Evangelist
> Nodejitsu, Inc.
> marak.squi...@gmail.com
>
>  --
> 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 nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> 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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to