I'm trying to write a simple app that preforms a db query when a user
connects to a tcp port.
I can get the query working if I do everything as callbacks:
db.open(... fn() {
db.collection(.... fn() {
db.query(...... fn() {
});
});
});
But as you can see this creates callback hell.
What I would like to do is have a class, but being as everything is
async it makes it incredibly difficult to ensure all your variables are
set.
var client;
db.connect(connect, fn(){
client = connect;
});
client.close();
Will cause an error because client hasn't been set yet. Another thing I
thought of doing was chaining it all together:
db.connect(connect, fn(){
...
process.nextTick(fn(){ doNext(); });
});
this gets very messy and hard to manage, how can I deal with callback hell?
--
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