To reply to my own very old thread after getting some solid experiences 
with promises, the answers to my questions are:

1. *async* is a library that passes callbacks around. it's ugly and it 
sucks.

2. a* promise *is just an object. Don't let anyone tell you differently, 
they are just trying to confuse you. It's an object that has method names 
that everyone's agreed on, like *then *and *done *which will magically 
trigger your callbacks for you. With promises, you include *Q* and you just 
pass around Q objects (called deferreds and promises). It's just that 
everyone agreed that the promise object will have a *.then* method, which 
you can call and your function jumps next in line onto the promise chain 
magically.

The libraries should *not *be used together. Once you get your head around 
promises and use them in field you won't want to use anything else.

If you are exposing an API, you should still take/call a callback. If 
you're writing a database client you don't want to give the user a promise 
and force them into your model. Just call their callback at the end of your 
own, internal beautiful promise chain. It will be our terrible secret.

Promises aren't perfect and can get strange when doing some complex 
composition (lots of return statements to return promise chains), but they 
make writing async code soooooo nice.

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