Hacker News new | past | comments | ask | show | jobs | submit login
Humane Promises/Futures for JavaScript (mootools.net)
3 points by swannodette on March 24, 2010 | hide | past | favorite | 1 comment



I've worked on this library for about 9 months and I can no longer stand to write traditional AJAX JavaScript code. When I first released it Node.js was only beginning to get traction. While I like Node.js, I think most of the code of I've seen to work around async heavy code is ugly as hell. So I'm hoping some of the ideas in my Promises.js might be useful someone.

Basically my philosophy is that async heavy code should look like and be testable as normal JavaScript. That is once a promise crosses a function that has been decorated with future, it will be realized. Now that may take some time, so the function returns a new promise for it's computation.

The main bit of innovation is that the "inside" of future decorated functions should look like regular JavaScript not a hideous mess of code for dealing with the fact that your arguments may be async.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: