Dammit Marak, you blitzed me ;P 

-Rick


On Monday, July 16, 2012 at 10:21 PM, Marak Squires wrote:

> Err.
> 
> Remove count = staff.length;
> 
> and like I said, use the async lib. 
> On Mon, Jul 16, 2012 at 7:19 PM, Marak Squires <[email protected] 
> (mailto:[email protected])> wrote:
> > 
> > > var staff = ["bill","mary"];
> > > var total = [];
> > > var count = 0;
> > > get_total_list(staff, function(err, callback) {
> > >   count = staff.length;
> > > 
> > >   for (var i=0; i<staff.length; i++) {
> > >     get_staff_children(staff[i], function(err, cb) {
> > >       total.push(cb);
> > >       count++;
> > >       if(count === staff.length) {
> > >         callback(err, total);
> > >       }
> > >     });
> > >   }
> > > });
> > 
> > But seriously, use https://github.com/caolan/async 
> > 
> > 
> > On Mon, Jul 16, 2012 at 7:15 PM, john.tiger <[email protected] 
> > (mailto:[email protected])> wrote:
> > > On 07/16/2012 07:41 PM, Martin Wawrusch wrote: 
> > > > This should help:  
> > > > 
> > > > https://github.com/caolan/async 
> > > honestly, we are having enough trouble with additional libraries - we 
> > > just want a simple solution with node code 
> > > 
> > > > 
> > > > 
> > > > On Mon, Jul 16, 2012 at 5:55 PM, john.tiger <[email protected] 
> > > > (mailto:[email protected])> wrote:
> > > > > stuck in async hell - page displaying (with null) before going thru 
> > > > > full loop and returning total with data - probably some simple funct 
> > > > > wrap but can't see it - thks for any help
> > > > > 
> > > > > var staff = ["bill","mary"];
> > > > > var total = [];
> > > > > get_total_list(staff, function(err, callback) {
> > > > >   for (var i=0; i<staff.length; i++) {
> > > > >     get_staff_children(staff[i], function(err, cb) {
> > > > >       total.push(cb);
> > > > >     });
> > > > >   }
> > > > >   callback(err, total || {});
> > > > > });
> > > > > 
> > > > > total => []
> > > > > 
> > > > > -- 
> > > > > 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] 
> > > > > (mailto:[email protected])
> > > > > To unsubscribe from this group, send email to
> > > > > [email protected] 
> > > > > (mailto:nodejs%[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] 
> > > > (mailto:[email protected])
> > > > To unsubscribe from this group, send email to
> > > > [email protected] 
> > > > (mailto:[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] 
> > > (mailto:[email protected])
> > > To unsubscribe from this group, send email to
> > > [email protected] 
> > > (mailto:nodejs%[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

-- 
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