That's overstating it a bit. It's very easy to convert to promise-based code,
e.g.:
var fs = require('fs');
var Q = require('q');
var readFile = Q.denodeify(fs.readFile);
var writeFile = Q.denodeify(fs.writeFile);
readFile('src.txt').then(function (result) { writeFile('dest.txt', result);
}).done();
Since this conversion process is pretty mechanical, there are several libraries
that have done it for you, e.g. https://npmjs.org/package/pr
________________________________
From: [email protected] [[email protected]] on behalf of Baz
[[email protected]]
Sent: Thursday, May 23, 2013 13:28
To: [email protected]
Subject: Re: [nodejs] Re: trying to wrap my head around "promises" - async vs Q
Thanks Matt, so just to be crystal clear, if I'm using promises in my own code,
then I happen to have a flow that depends on fs, for example, and since fs
doesn't return or use promises, I would have to drop out of the promises
paradigm and manage that particular part of the flow control with callbacks or
something like asynch?
On Thu, May 23, 2013 at 7:01 AM, Matt
<[email protected]<mailto:[email protected]>> wrote:
On Thu, May 23, 2013 at 3:29 AM, Baz
<[email protected]<mailto:[email protected]>> wrote:
I am new to Node and trying to decide between promises, asynch and vanilla,
there are so many good arguments for each. Mikeal, do you mind expanding
further how using promises in your own, non-shared, code could hinder use of
node? Do a lot of the libs that depend on asynch require you to use asynch as
well (or make things easier if you do)?
I think the problem with promises is that the core node libraries aren't
implemented with promises, so if you need to do a series of e.g. fs calls
(typical example might be open, then stat, then create a readStream from the
fd) you wind up using async anyway, or manually coding up the nested callbacks,
which can feel ugly once you've started using a particular flow control
library. And then once you start using async for one thing, it just starts to
feel natural. It just fits so perfectly with the Node ecosystem.
In short: There's nothing wrong with the promises model (although I find it
overly verbose), it's just that async fits better with node libraries.
Matt.
--
--
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
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
[email protected]<mailto:nodejs%[email protected]>.
For more options, visit https://groups.google.com/groups/opt_out.
--
--
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
---
You received this message because you are subscribed to a topic in the Google
Groups "nodejs" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/nodejs/mWtqFE0spWk/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.
--
--
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
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.