|
|
|
|
|
by diamondhead
5381 days ago
|
|
JavaScript itself gives developers enough power to beautify messy async code, already. Below is the rewrite of the first example in that page, with async function composition: ==== /* https://gist.github.com/1250314 */ var db = require('somedatabaseprovider'), compose = require('functools').compose;
compose.async(getApp, connect, select)({ url:'/price', host:'host', pass:'123' }, function(error, shift){ shift.conn.close();
shift.res.send(shift.products[0]);
});==== It's that easy to abstract those messy callbacks using some functional tools. |
|