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 <[email protected]> wrote:
> On Tue, Mar 20, 2012 at 10:58 AM, Angelo Chen <[email protected]> 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 [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