process.nextTick?
I've taken a very quick look at the code, because I like the idea of typescript + dataloader wo/ caching, but I'm finding the underlying mechanisms seems to be quite different.
DataLoader, when run on Node, relies on process.nextTick -see enqueuePostPromiseJob- to maximize performance, setImmediate on browsers where it's available, or setTimeout as a fallback, as it's the least performant.
As far as I could see, this module is simply using setTimeout with a delay in order to batch all requests within a time frame which, I would consider a nice extra feature, but not great as a default. I was wondering whether there was a particular reasoning behind it, or whether maybe I just got this whole thing wrong.
Thanks!
I disagree @rafamel. The problem with nextTick is that it's Node-specific. For that reason, I can only use dataloader in Node, whereas with batchloader I can use it in Node, Deno, or the browser, which is a huge advantage.
What makes you think nextTick is more performant than setTimeout(fn, 0)? Do you have a link that says these node microtasks are actually more performant than the macrotasks created by setTimeout? Even if nextTick is more efficient, the resulting trade-off of therefore only being able to use it in Node is a huge compromise for what is only a slight efficiency gain.
Lastly, if you're going to reference code in other projects, use a permalink.