Skip to content

Ever considered the use of queueMicrotask? #348

@andreyvital

Description

@andreyvital

It's available as of v11—isn't it better than process.nextTick? https://nodejs.org/api/globals.html#queuemicrotaskcallback

dataloader/src/index.js

Lines 239 to 255 in d336bd1

const enqueuePostPromiseJob =
typeof process === 'object' && typeof process.nextTick === 'function'
? function (fn) {
if (!resolvedPromise) {
resolvedPromise = Promise.resolve();
}
resolvedPromise.then(() => {
process.nextTick(fn);
});
}
: typeof setImmediate === 'function'
? function (fn) {
setImmediate(fn);
}
: function (fn) {
setTimeout(fn);
};

Just a question...

Thanks,
A.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions