Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fully composable denodeify #213

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

Fully composable denodeify #213

domenic opened this issue Feb 21, 2013 · 8 comments

Comments

@domenic
Copy link
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
Copy link
Collaborator

👍 from me

@kriskowal
Copy link
Owner

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

@ForbesLindesay
Copy link
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
Copy link
Collaborator Author

domenic commented Feb 21, 2013

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

@kriskowal
Copy link
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
Copy link
Collaborator Author

domenic commented Feb 28, 2013

For reference implicit promised is tracked as #160.

@domenic
Copy link
Collaborator Author

domenic commented Jul 9, 2013

Small back-compat hazard; tagging as such.

@kriskowal
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants