3 ms·
Don't get me wrong, this could end up being the best thing since sliced bread, but the advantage of closures is that a higher-order approach can work wonders.
by moomin 16y ago
Don't get me wrong, this could end up being the best thing since sliced bread, but the advantage of closures is that a higher-order approach can work wonders. Just take a look at async.js.
For me, more interesting than a pure assault on callbacks would be to see if you could handle more asynchronous scenarios, using async.js as a baseline.
e.g. callback waterfall, callback when all children are finished, callback when any children are finished
- randylahey 16y agoI wish this was rated higher. I don't understand the fuss about "spaghetti code". Do all those people write spaghetti code in other languages? Because I see that not as a language failing but as sloppy programming. What's so hard about this to get a sequential execution of functions/blocks, error'ing out on the first error: async.waterfall( [ function (callback) { // do thing 1 callback(); } , function (callback) { // do thing 2 callback(); } , function (callback) { // do thing 3 callback(); } ] , function (error) { if (error) { // ohnoes errors } // all done! } );