Uh oh!
There was an error while loading. Please reload this page.
Square with the promise of being an async API - #23
Conversation
yhahn
commented
Jul 15, 2014
Heh is this a new convention. |
sethfitz
commented
Jul 15, 2014
Not really. All it does is ensure that all API callbacks are executed asynchronously instead of just those that are inherently async. Without the E.g. functionfoo(){getInfo(function(err,info){console.log("1");});console.log("2");}Given that However, if I remember reading a blog post that drives the point home a bit more effectively, but I can't find it. |
yhahn
commented
Jul 15, 2014
@mojodna yes I'm familiar with what this is doing. However is this a new convention throughout node core? As far as I know just because a function takes a callback does not mean that it is implied the callback will be called in the next tick. |
sethfitz
commented
Jul 15, 2014
Not that I know of (though it is a common use of |
yhahn
commented
Jul 15, 2014
Cool, help me understand what actual concrete things this will solve for you... I have run into this before but usually consider it a failure of my own expectations -- passing a callback doesn't promise anything about what tick/call order is about to happen next in my mind, and if I need an explicit call order I implement it from the calling code. |
sethfitz
commented
Jul 15, 2014
Nothing, honestly. I was in there working on #24 (and #22) and figured I'd straighten up while I was at it. I'd consider it a failure of the libraries you're using, not your own. Coding defensively by choice / habit is one thing, coding defensively by necessity is unfortunate. I generally assume "future", but it's rare that I actually rely on that behavior (and when I do, I suppose I also fall back to being explicit). |
springmeyer
commented
Dec 24, 2014
Saw kelektiv/node.bcrypt.js#264 go by, which provides a bunch of supporting links. |
yhahn
commented
Dec 24, 2014
y closing -- this is not a consistent expectation in the node ecosystem. |
Async API is async. (Sorry, the link to support this this isn't handy.)