matthew-andrews/denodeify

Document using denodeify against a method

Closed this issue · 5 comments

It would be great if the documentation would mention how to denodeify methods as well as functions; perhaps something like this (borrowing from the Q library documentation):

Note that if you have a method that uses the Node.js callback pattern, as opposed to just a function, you will need to bind its this value before passing it to denodeify, like so:

var Kitty = mongoose.model("Kitty");
var brokenFind = denodeify( Kitty.find ); // the find method won't have the right 'this' defined
var findKitties = denodeify( Kitty.find.bind(Kitty) );

Great idea 👍. It could go as a second example before the line More complex example….

Is this something you would be happy to prepare a pull request for or would you prefer if I typed something up?

If the text above works as-is, I'll be happy to do a pull request -- but if you'll want to change it anyway, it probably makes sense for you to write it up... the latter would be my preference I suppose :-)

Thanks!

I just got stuck for an hour about that. @BrianRossmajer, the text you wrote is perfectly clear, I think it is fine. Could you submit a PR if @matthew-andrews is ok?

my bad I completely missed @BrianRossmajer's comment. I've done this:

#24

Looks great to me, thanks!