Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Why is 'require' not doing callbacks?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Martín Ciparelli  
View profile  
 More options May 15 2012, 2:30 pm
From: Martín Ciparelli <mcipare...@gmail.com>
Date: Tue, 15 May 2012 15:30:20 -0300
Local: Tues, May 15 2012 2:30 pm
Subject: Re: [nodejs] Why is 'require' not doing callbacks?

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+unsubscribe@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+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en


 
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.