Fully composable denodeify #213

Closed
domenic opened this Issue Feb 21, 2013 · 8 comments

Projects

None yet

3 participants

@domenic
Collaborator
domenic commented Feb 21, 2013

when.js got a method, they call it bind, that creates "fully composable" promise functions from Node functions:

var readFile = whenBind(fs.readFile);
var writeFile = whenBind(fs.writeFile);

writeFile("destination", readFile("source"));

This could be implemented pretty easily by composing Q.promised and Q.nfbind. I propose it as the new implementation of denodeify, which currently in master (never released) is just a synonym for nfbind. Like so:

Q.denodeify = function (nodeFunc) {
  return promised(nfbind(nodeFunc));
};

Sound good?

@ForbesLindesay
Collaborator

👍 from me

@kriskowal
Owner

How do you feel about making promised implicit to message dispatch?

@ForbesLindesay
Collaborator

Promised currently causes a few extra calls to nextTick which may be worth attempting to optimize out if we're going to be using it a lot.

I'm broadly in favor of using it everywhere though.

@domenic
Collaborator
domenic commented Feb 21, 2013

Not sure. Will think about it more. Perf certainly could be an issue.

@kriskowal
Owner

Punting this to a future version. I need to play with the idea of implicit promised in both the general and specific cases.

@domenic
Collaborator
domenic commented Feb 28, 2013

For reference implicit promised is tracked as #160.

@domenic
Collaborator
domenic commented Jul 9, 2013

Small back-compat hazard; tagging as such.

@kriskowal
Owner

I believe that generators make this a non-issue. Closing. Please feel free to reopen if you have strong feelings about this direction.

@kriskowal kriskowal closed this Oct 20, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment