4 ms·
I'm currently working on porting dojo.Deferreds to node.js. On top of them I am also working on some API sugar that makes it really easy to aggregate the result
by felixge 17y ago
I'm currently working on porting dojo.Deferreds to node.js. On top of them I am also working on some API sugar that makes it really easy to aggregate the results of multiple deferreds:
(group)
('a', db.query('SELECT A ...'))
('b', db.query('SELECT B ...'))
('c', db.query('SELECT C ...'))
.addCallback(function(results) {
p(results) // {a: ..., b: ..., c: ...}
});
This will make it very easy to run multiple things in parallel, yet handle all of them in one callback.
Check http://github.com/felixge/node-deferred http://github.com/felixge/node-deferred for more info.
Do not use wait() too much, it will be memory expensive.
- amix 17y agoDeferred[1] is originally used in Python's Twisted framework. It's also used in Bob Ippolito's MochiKit's library. Generally, it's a great abstraction and I am looking forward to see your results. As I recall Twisted has an ability to chain deferrers. [1] http://twistedmatrix.com/documents/current/core/howto/defer.html http://twistedmatrix.com/documents/current/core/howto/defer....