3 ms·
Just curious, is there a good futures library for Node? If so, you could write code of the form: x = db.getFutureResult("x"); y = db.getFutureResult("y
by yummyfajitas 15y ago
Just curious, is there a good futures library for Node? If so, you could write code of the form:
x = db.getFutureResult("x");
y = db.getFutureResult("y");
whenFuturesReady([x,y], callback(x, y) {
useResults(x,y);
});
This looks reasonably similar to typical synchronous code,
x = db.getResult("x")
y = db.getResult("y")
useResults(x,y)
but it allows db queries to happen simultaneously and doesn't break the node paradigm.
- papaf 15y agoIt never became production ready, but I found this article an interesting discussion of the problem and a solution to it in Coffeescript: http://gfxmonk.net/2010/07/04/defer-taming-asynchronous-javascript-with-coffeescript.html http://gfxmonk.net/2010/07/04/defer-taming-asynchronous-java...