News for hackers. Stuff that matters.
Re:Accessing a MySQL database from Node.JS by felixge on Monday December 07, 2009 @01:08PM (#981654)
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 for more info.

Do not use wait() too much, it will be memory expensive.

Re:Accessing a MySQL database from Node.JS by amix on Monday December 07, 2009 @01:22PM (#981694)
Deferred[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....

Re:Accessing a MySQL database from Node.JS by blasdel on Monday December 07, 2009 @04:12PM (#982167)
The whole point is that they innately bind to one another -- they are, after all, monadic (gasp!)
Re:Accessing a MySQL database from Node.JS by amix on Monday December 07, 2009 @11:17PM (#983001)
It's very easy to define bind and return for event driven code, so most event driven programming is or can become monadic.