NodeJS: process.nextTick vs Instant Callbacking

前端 未结 2 1277
情深已故
情深已故 2021-02-05 14:22

I write lots of modules which look like this:

function get(index, callback) {
    if (cache[index] === null) {
        request(index, callback); // Queries datab         


        
2条回答
  •  滥情空心
    2021-02-05 15:06

    http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony

    if you're doing callbacks internally, do whichever is suitable

    if you're creating a module used by other people, asynchronous callbacks should always be asynchronous.

提交回复
热议问题