A bit out of topic, as we are all agreed async api should be always async, 
one can use setImmediate, because it will perfectly fit our needs, because 
it supports arguments (vs. nextTick) and doesn't requires delay in ms 
(setTimeout).

So the writing overhead by using it is pretty minimal:


if (err) {
    return callback(err);
}

vs.

if (err) {
    return setImmediate(callback, err);
}



On Tuesday, August 20, 2013 7:47:22 PM UTC+2, Bryan Donovan wrote:
>
> I have been writing node.js client code for a couple of years now, and 
> have authored a couple open source libraries, but somehow I missed the memo 
> telling me that I'm supposed to wrap 'synchrounous' callbacks in 
> process.nextTick().  I kind-of understand why that is a best-practice, but 
> what I don't understand is what the drawback is if you don't do it.
>
> For example, I write code like this all the time, and have never had a 
> single problem with it:
>
> function getSomething(args, cb) {
>     if (!args) { return cb(new Error('args required')); }
>     if (!args.id) { return cb(new Error('args.id required')); }
>
>     SomeDatabase.get({id: args.id}, cb);
> }
>
> What are the potential issues with not wrapping those arg checks in 
> process.nextTick()?
>
>
> Thanks, 
>
> Bryan
>

-- 
-- 
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