Thanks for the post, Isaac.  Very helpful.

I totally understand the logic of being consistent -- I'm known to be ruthless 
about consistency at work.   I'm changing my public node.js libraries to use 
nextTick() instead of calling back immediately.

However, I'm still unsure of when someone would ever care if I called back 
immediately in my examples, where I'm just checking for the correct args.  An 
example use case:

var db = {
    get: function(args, cb) {
        args = args || {};
        if (!args.index) { return cb(new Error('index required')); }
        if (!args.type) { return cb(new Error('type required')); }

        doSomethingAsync(args, cb);
    }
};

function getSomething(args, cb) {
    db.get(args, cb);
}

// Express.js-style route 
app.get('/foo', function(req, res) {
    var args = {index: req.params.index, type: req.params.type, id: 
req.params.id};
    getSomething(args, function(err, result) {
        if (err) {
            res.send(500, JSON.stringify(err));
        } else {
            res.send(200, JSON.stringify(result));
        }
    });
});

This is how I'd expect people to use this client.  I must still be missing 
something, but *in this situation* I still don't see where someone would run 
into trouble due to the error callbacks being returned immediately.

Thanks,
Bryan

On Aug 28, 2013, at 6:16 PM, Isaac Schlueter <i...@izs.me> wrote:

> Bryan,
> 
> I wrote this for you.
> http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony
> 
> On Fri, Aug 23, 2013 at 10:58 AM, Scott González
> <scott.gonza...@gmail.com> wrote:
>> On Fri, Aug 23, 2013 at 1:46 PM, Chaoran Yang <chaoran.y...@gmail.com>
>> wrote:
>>>> 
>>>> I have never seen such cases ... and can't imagine them ... but
>>>> potentially yes ...
>>> 
>>> 
>>> The cursor.nextObject() of node-mongodb-native that @Eldar has brought up
>>> is a pretty good one.
>> 
>> 
>> Are there real world benchmarks showing that this is a legitimate
>> performance bottleneck?
>> 
>> --
>> --
>> 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 nodejs@googlegroups.com
>> To unsubscribe from this group, send email to
>> nodejs+unsubscr...@googlegroups.com
>> 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 nodejs+unsubscr...@googlegroups.com.
>> 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 nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> 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/0TmVfX9z1R0/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to 
> nodejs+unsubscr...@googlegroups.com.
> 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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
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 nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to