3 ms·
Next time you're about to define a function with a callback argument, don't. No, do. It's the prevailing style in Node.js and elsewhere, and so there exist too
by quarterto 14y ago
Next time you're about to define a function with a callback argument, don't.
No, do. It's the prevailing style in Node.js and elsewhere, and so there exist tools to transform them (syntactically or otherwise) into more palpable styles:
https://github.com/0ctave/node-sync https://github.com/0ctave/node-sync
https://github.com/BYVoid/continuation https://github.com/BYVoid/continuation
https://github.com/JeffreyZhao/wind https://github.com/JeffreyZhao/wind
https://github.com/Sage/streamlinejs https://github.com/Sage/streamlinejs
- joshguthrie 14y agoI already knew about node-sync, but continuation really brings something new. I'll check the source to understand what it does under the hood.
- j_s 14y agoAlso, the comparison on the project's README is informative (and lists additional options): https://github.com/BYVoid/continuation#relevant-projects https://github.com/BYVoid/continuation#relevant-projects
- craigyk 14y agoI agree, I often will write promise wrappers for other people's stuff, but for the external surface of my module I have callbacks. Also, callbacks ARE sometimes nicer than promises, etc... especially if you have CoffeeScript function syntax.