ok, i see the point, it is syncronous, then when it was mixed with
asynchronous callbacks, how to deal with this? here is an example, cb
should be called after all member has been console.log, but it turn
out different:


exports.get_list = function ( cb) {
                rclient.smembers("list", function(err, members) {
                        members.forEach(function(member){
                                console.log(member)
                                rclient.hgetall(member, function(err, item) {
                                                console.log(item)
                                })
                        })
                        cb(null, 'lst')
                })
}


On Mar 20, 6:02 pm, Oliver Leics <oliver.le...@gmail.com> wrote:
> On Tue, Mar 20, 2012 at 10:58 AM, Angelo Chen <angelochen...@gmail.com> wrote:
> > the function(member) for 'forEach' is callback, right? then why,
> > cb(null,'lst') will wait until the loop is over?
>
> .forEach on arrays is syncronous. Like Bruno sayed, dont equate
> "asynchronous" with "callbacks"

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